Java Coding Conventions

78 views.

Every predefined class, interface, method etc. will follow the java coding conventions and we are recommended to follow the same conventions. It is always a good programing practice to develop a program by following the coding conventions.

Conventions for a class

A class name can contain any number of words and the first letter of every word should be specified in uppercase

Example: System StringBuffer   SecondProgram

Conventions for interface

An interface name can contain any number of words and the first letter of every word should be specified in uppercase.

Example: Runnable ActionListener  MyInterface

Conventions for Method

A method name can contain any number of words and the first word should be specified completely in lower case. The first of the remaining  words should be specified in uppercase.

Example: main() toCharArray() areaOfSquare()

Conventions for Variable

A variable name can contain any number of words and the first word should be specified completely in lower case. The first of the remaining  words should be specified in uppercase.

Example: length numberOfStudents accountNumber

Conventions for constant

A constant name can contain any number of words. All the letters of all words  should be specified in uppercase, if multiple words are aviable then separate them by underscore(_)

Example: MIN_VALUE MAX_PRIORITY PI

Conventions for package

A name should be specified completely in lowercase with minimum one Dot(.) separator

Example: java.lang java.net  androindian.example

 

 

Leave a Reply