-
Notifications
You must be signed in to change notification settings - Fork 2
1.1.7 White Spaces
Two blank lines should always be used in the following circumstances:
- Between sections of a source file.
- Between classes and interfaces settings.
A blank line should always be used in the following circumstances:
- Among methods.
- Between a local variable in a method and its first statement.
- Before a block comment or a review of a single line.
In any instruction that makes use of multiple fields separated by commas, put a blank space after the comma.
In any instruction that makes use of parentheses, put a blank space separating the inner contents of the parentheses itself.
public void make ( int arg1, int arg2, String arg3 ) throws EOFException {
/* Write Instructions Here. */
}
In any structure that makes use of parentheses, put a blank space separating the inner contents of the parentheses itself.
if( condition ) {
/* Write Instructions Here. */
} else {
/* Write Instructions Here.
* or
* Nothing To Do.
*/
}
for( int i = 0; i < length; i++ ) {
/* Write Instructions Here. */
}
do {
/* Write Instructions Here. */
} while( condition )
switch( sum ) {
case 1:
/* Write Instructions Here. */
case 2:
/* Write Instructions Here. */
case 3:
/* Write Instructions Here. */
case 4:
/* Write Instructions Here. */
default:
/* Write Instructions Here. */
}
while( condition ) {
/* Write Instructions Here. */
}
try {
} catch( Exception e ) {
} finally {
}
In any instruction that makes use of binary operators, put a blank space on both sides of the binary operator.
int a = -4 + 9;
b = a++ / --sum;
c += 4;
In calling methods, put a space and white after opening parenthesis and before closing it unless the parameter list is empty.
surf();
make( books, cookies, children );
String string = new String();
Point point = new Point( x, y );
The use of parentheses in expressions, put a space and white after opening parenthesis and before closing it.
result = ( a * ( b + c + d ) * ( e - f ) );
In allocating arrays, put a space and white after opening the bracket and before closing it.
The access array elements, put a space and white after opening the bracket and before closing it.
int[] array1 = new int[] { 1, 2, 3 };
int[] array2 = new int[ 3 ];
array2[ 1 ] = array1[ 2 ];