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?
- 2Guess you should contact James Gosling :)Balwinder Singh– Balwinder Singh2014-04-07 13:08:11 +00:00Commented 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.T.J. Crowder– T.J. Crowder2014-04-07 13:10:42 +00:00Commented 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?David– David2014-04-07 13:10:52 +00:00Commented Apr 7, 2014 at 13:10
- 4Functions are not called methods in java. Your premise is wrong because you don't know what the differences between the two are.Sotirios Delimanolis– Sotirios Delimanolis2014-04-07 13:11:40 +00:00Commented 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.David– David2014-04-07 13:33:10 +00:00Commented Apr 7, 2014 at 13:33
| Show 7 more comments
3 Answers
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.
Comments
Why functions are called methods in java?
- A method is on an object.
- A function is independent of an object.
- For Java, there are only methods.
- 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
Joffrey
Well, IMHO static methods are closer to functions in this respect. But I mostly agree with you.