您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes
Introduction
Content
Apply
Reflect
Extend
previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Content Index
Content Page # 18

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.
 

image2.gif (960 bytes) Exercise 4 ?Layout

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright © 1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg