naming convention in java with example

SNo. Name Convention Example
1. package name should be start with in lowercase letter  java, lang, sql, util etc
2. class name should start with uppercase letter and be a noun  String, System, Firefox, DataInput, Thread 
3. interface name should start with uppercase letter and be an adjective Runnable, Remote, ActionListener
4. method name should be start with in lowercase letter, then from second word onwards, each new word starts with a uppercase letter. method's name ends with a simple pair braces() print(),readLine(),test(),collegeName()
5. variable name should be start with in lowercase letter, then from second word onwards, each new word starts with a uppercase letter. It is same like as for method, but variable names not have any pair braces in after variable name end.  print,readLine,test,collegeName
6 constants name should be written in all uppercase letters PI, MAX_VALUE,MAX_PRIORITY
7 keywords all keywords should be written in all lowercase letters class,public,static,void,do-while,for,break,etc..In the Java programming language, a keyword is one of 50 reserved words.

 

Comments