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

 
 
Apply Index
Apply Page # 9

Exercise 4 ?Layout

Here is a section of a Java program where no layout convention has been enforced. It is a complete mess. Use indentation, spaces and blank lines as appropriate to tidy up the program and make it easier to follow. Compare your solution with the suggestions given in the answer, and see which you prefer. 

class Untidy  {  int result;  public static void main (String args)    {
int x = calculate();    show(x);    }
void show(int x)    {    System.out.println(x);    }
int calculate()    {    result = 0;    for (int i = 0; i < 100; i++)
result = result + i;    return result;   }  }

Answer

Back  to content

Back to top

basicline.gif (169 bytes)

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