logo
Java Naming Convensions
JAVA NAMING CONVENSIONS

Java is a case sensitive language so the way of writing code is important.
1. All Java classes,Abstract classes and Interface names should start with uppercase letter ,if any class contain more than one word every innerword also start with capital letters.

Ex:  String
StringBuffer
FileInputStream

2. All java methods should start with lower case letters and if the method contains more than one word every innerword should start with capital letters.

Ex :  post()
toString()
toUpperCase() 

3. All java variables should start with lowercase letter and inner words start with uppercase letter.

Ex:  pageContent
bodyContent

4. All java constant variables should be in uppercase letter.

Ex:  MIN_PRIORITY
 MAX_PRIORITY
NORM_PRIORITY

5. All java packages should start with lower case letters only.

 Ex:  java.awt
Java.io
JAVA COMMENTS :-
To provide the description about the program we have to use java comments.
There are 3 types of comments present in the java language.

1) Single line Comments:-

By using single line comments we are providing description about our program within a single line.
Starts with-------->// (double slash)
Syntax:- //description

2) Multi line Comments:-

This comment is used to provide description about our program in more than one line.

Syntax :  
/* 
line-1 
 line-2  
*/

3) Documentation Comments:-

This comment is used to provide description about our program in more than one page.
In general we are using document comment to prepare API kind of documents but it is not sujastable. 

 Syntax : 
/* 
.line-1
..line-2
line-3
*/

Ex: 
/*project name:-green project
team size:- 2
team lead:- freetimelearning.com 
*/
class Test
{
//main method
public static void main(String[] args)
{
//printing statement
System.out.println("freetimelearning.com");
}
};