July 22, 2014
Java naming conventions
Java naming conventions are “rules” which a developer decide to use in his code. These rules are meant to make your code more understandable and easier to read for other developers. At first SUN, and then Oracle conventions to name the different Java types (packages, classes, interfaces, methods, variables and constants).
Some of the naming conventions are :
- Packages names should be all in lowercases;
- Classes and interfaces names should be capitalized;
- Methods names should be verbs;
- Variables names should be as short as possible, but meaningful.
For the exam you have to pay attention on questions regardless to the java legal identifier and to the java code convention. For example, a java variable name could be legal, but not recommended.
2 Comments
Java naming conventions made the program more readable. Though not following it would not issue an error but it is considered a good programming practice to follow naming conventions.
See this : Java naming conventions for the rules that are defined for naming classes, methods, variables etc.