Programs should be indented properly to make them easier to read:
{ brace → increase indent of following lines by one tab
} brace → decrease indent of that line and following lines by one tab
Example:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
System.out.println("How are you?");
}
}
Make sure that your Neighbors program has good indentation.
continued on the next slide...
Our Indenter Tool web page can fix a program's indentation.
In this exercise, we will use the Indenter Tool to fix the following program that has poor indentation. Download it and open it in jGRASP:
continued on the next slide...
public class Icky {
public static void main(String[] args) {
System.out.println("Well-indented programs");
System.out.println("look much better.");
System.out.println("Please fix me");
System.out.println("so I look nicer");
}
}
|