In order to maintain readability of code it is important to be able to identify the purpose of an identifier quickly. In the pursuit of this goal Java has adapted the following conventions about capitilization of identifiers.
The first letter of each word in a class name should be capitalized. All other letters should be lower case.
The first letter of each word of a variable or method should be capitalized, saving the first word. All other letters should be lower case.
For purposes of easier readability code blocks such as those contained within while and for loops, if-else statements, and class structures themselves should be indented. These conventions are much easier to illustrate than explain.
if(x < 5) x--; (Note: Indentation should be 3 spaces)One line code block with braces.
if(x < 5) { System.out.println("Low Value Obtained"); } OR Any of the styles used for multi-line code blocksMulti-line code bocks
while(!done) (Note: Indentation should be 3 spaces.) { x = getNextValue(); done = isSmallest(x); } OR while(!done) { (Note: Again indentation should be 3 spaces.) x = getNextValue(); done = isSmallest(x); } OR while(!done) { x = getNextValue(); done = isSmallest(x); }Note: Class definition blocks should use only the first or second example.