2

Why functions are called methods in java. I am not asking the difference between the two. Why Java community choose to name them methods. Is there any concrete reason behind this decision or it's just a name? When i think of literal meaning as far as i could think function is related to internal working of some machine. Method is a way of working to achieve a goal(mathematical solution) or may be method is a way of implementing an Object. Is that where it came from or i just missed the real picture?

12
  • 2
    Guess you should contact James Gosling :) Commented Apr 7, 2014 at 13:08
  • 1
    @Mr.Pandey: Actually, you are, basically. The terms mean different things. The correct term for what Java has is "method", for the reasons given in the answer to that question. So that's the term they used. Commented Apr 7, 2014 at 13:10
  • 1
    @Mr.Pandey: If you're not asking for the difference between the two, then what are you asking? If you know the difference (which, admittedly, I didn't until recently) then what is unclear? Commented Apr 7, 2014 at 13:10
  • 4
    Functions are not called methods in java. Your premise is wrong because you don't know what the differences between the two are. Commented Apr 7, 2014 at 13:11
  • 1
    @Mr.Pandey: I'm saying that the words "function" and "method" in this context have specific meanings. Java chose to call them "methods" because they fit the already-existing meaning of that word. Had they called them "functions" they would be introduced confusion because that word already has a different meaning. Commented Apr 7, 2014 at 13:33

3 Answers 3

13

It's not in Java, it's an OOP name.

In sort, it defines part of the behavior of an instance of an object, not a general operation.

Sign up to request clarification or add additional context in comments.

Comments

1

Every language has it's own syntax to differentiate from others. As for your question

Functions existence is independent.

Methods do not as they are created within the class.

Comments

1

Why functions are called methods in java?

  1. A method is on an object.
  2. A function is independent of an object.
  3. For Java, there are only methods.
  4. For C, there are only functions.

For C++ it would depend on whether or not you're in a class.

In languages such as C++, functions are bits of code that will perform a particular action - but are not associated with an object. functions that are to do with an object are called methods. in java all functions are methods as they are all to do with objects.

1 Comment

Well, IMHO static methods are closer to functions in this respect. But I mostly agree with you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.