Home >Java >javaTutorial >Are method names and class names the same in java?
No, method names and class names in Java are usually different because methods and classes need to be uniquely identified within the same class. The method name usually describes the function of the method, while the class name usually describes the concept represented by the class.
Method name and class name in Java
Answer:
No, Java The method names and class names in are usually different.
Expand:
The class name in Java is used to identify the class, and the method name is used to identify the method in the class. The two must be different because methods and classes must be uniquely identifiable within a class.
Method names are usually verbs or verb phrases that describe the function or purpose of the method. For example, if a method adds two numbers, its name might be add
.
Class names are usually nouns or noun phrases that describe the concept represented by the class. For example, if a class represents a car, its name might be Car
.
Other notes:
$
symbols to distinguish them from outer classes. The above is the detailed content of Are method names and class names the same in java?. For more information, please follow other related articles on the PHP Chinese website!