Java Naming Conventions, Before discussing this chapter Splesson will teach one important thing is that Java is a case sensitive language. The Java Naming Conventions is a rule to follow to name identifiers like class, package, variable, constant, method. Naming conventions make programs more understandable by making them easier to read. One can also give information about the function of the identifier. For example, whether it’s a constant, package, or class-which can be helpful in understanding the code.
In Java Naming Conventions, Package name should be in lowercase letters.
Example:Java, sql, lang, util. Acceptable: com.spl.packagename Unacceptable: com.spl.package_name
Class Names are always nouns, not verbs. Class Name should start with Capital Letter and if there are multiple words in the class name then each word must also begin with a capital letter.
Example:Color, System, Thread, String, Button. Acceptable: class ClassName Unacceptable: class classname
In Java Naming Conventions, Interface names are always an adjective. Interface Name should start with Capital Letter and if there are multiple words in the interface name, then each word must also begin with a capital letter.
Example:Remote, ActionListener, Runnable. Acceptable: interface InterfaceName Unacceptable:interface interfacename
In Java Naming Conventions, Method Names are typically verbs. Method Names should start with a lowercase letter.
Example:main(), println(), print(), actionPerformed() Acceptable: void getId(); Unacceptable: void GetId();
Do not use abbreviations, use full names. Variable name should start with a lowercase letter.
Example: firstName, orderNumber Acceptable: int empId; Unacceptable: int EmpId;
Java follows camelcase syntax for naming the class, interface, method and variable.
If name is combined with two words, second word will start with uppercase letter always e.g. actionPerformed(), firstName, ActionEvent, ActionListener.
The Java Naming Conventions are the rules.
All the packages will be separated with dot extension like import java.io.