pattern exercises for java

Solutions on MaxInterview for pattern exercises for java by the best coders in the world

showing results for - "pattern exercises for java"
Antonia
27 Oct 2020
1      // Outer loop to print each of the rows
2      for (int row = 1; row <= size; row++) {  // row = 1, 2, 3, ..., size
3         // Inner loop to print each of the columns of a particular row
4         for (int col = 1; col <= size; col++) {  // col = 1, 2, 3, ..., size
5            if ((row % 2) == 0) {   // row 2, 4, 6, ...
6               ......
7            }
8            System.out.print( ...... );   // Use print() without newline inside the inner loop
9            ......
10         }
11         // Print a newline after printing all the columns
12         System.out.println();
13      }