// improved version of Diamond2.java that uses a constant to // adjust the size of the diamond public class Diamond3 { public static final int SIZE = 3; public static void main(String[] args) { topHalf(); bottomHalf(); } public static void topHalf() { for (int row = 0; row < SIZE; row++) { // spaces for (int i = 0; i < (SIZE - 1) - row; i++) { System.out.print(" "); } // single / System.out.print("/"); // dots for (int i = 0; i < 2 * row; i++) { System.out.print("."); } // single \ System.out.print("\\"); System.out.println(); } } public static void bottomHalf() { for (int row = (SIZE - 1); row >= 0; row--) { // spaces for (int i = 0; i < (SIZE - 1) - row; i++) { System.out.print(" "); } // single / System.out.print("\\"); // dots for (int i = 0; i < 2 * row; i++) { System.out.print("."); } // single \ System.out.print("/"); System.out.println(); } } }