Nested Repetition

Nested repetition is when a control structure is placed inside of the body or main part of another control structure. Java allows you to put any construct inside of any other construct. However, you may not have them partially overlap each other.

Nested repetition are often used for processing things like multi-dimensional arrays.

Write a code that prints each value of a 2D array.

for (int i = 0; i < array.length; i++) {
   for (j = 0; j < array[i].length; j++)
      System.out.print(array[i][j] + " ");
   System.out.println();
}

Fook Yuen Sin - Team 1