Exercise : Practice indentation

Programs should be indented properly to make them easier to read:

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...

Exercise : Practice indentation, cont'd

Our Indenter Tool web page can fix a program's indentation.

indenter tool screenshot

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...

Exercise : Practice indentation, cont'd

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");
   }
}