Layout
convention: statements on separate lines
The Java compiler actually ignores
new-line characters except when they occur inside the double quotation
marks of a string. So it is possible to write multiple statements, or even
a whole program, all on a single line. Consider the following program,
which the JDK happily compiles and runs with no complaints:
class
Style{public static void main(String args[]){System.out.println("it takes
all kinds");}}
The same program written again, following
the layout conventions suggested in this unit is as follows:
class
Style
{
public static void main( String args[] )
{
System.out.println( "it takes all kinds" );
}
}
Hopefully you will agree that for humans,
the use of layout and naming conventions can make
Java code much more easy to read, and therefore understand and debug.
Back
to top
RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex
University. All rights reserved.
webmaster@globalcampus.com.eg
|