Explain class, method, function? [closed]
I am not clear what these terms mean:
-
开发者_JS百科
- Class
- Method
- Function
Can you please explain these terms to me?
You should first begin with Object Oriented development (maybe http://en.wikipedia.org/wiki/Object-oriented_programming). Because the class, method and function topics are not Java-specific.
Then you can see how Java works and how to build classes with it.
A class is a way of representing a group of objects. Sun/Oracle describes more about a class in What is a class? For example a car is a class of motorized vehicles with four wheels (among other things)
A method is a section of code that is declared to take some arguments (things like numbers) and return a value of a given type. A method has a body that determines what it does. Other parts of your code can call that method, at which point the code in your method is run and the return value can be used by the code doing the calling.
The word function is not really used when discussing Java, but if it is used it is a synonym for method.
精彩评论