Complete the code for row-wise 2D array iteration

Report a typo

You have been given a partial code snippet of a Java program that should print the contents of a 2D array in a row by row manner. The array has been already defined for you and several print statements are also included. However, few parts of the code are missing. Your task is to fill the blanks in code to create a functional program that correctly iterates over the array using nested loops and outputs every element of the array. Remember, the array could have varying lengths for its rows.

Fill in the gaps with the relevant elements
public static void main(String[] args) {
    int[][] array = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };
     (int i = 0; i < ; i++) {
        for (int j = 0; j < array[i].length; j++) {
            System.out.print(array[i][j] + " ");
        }
        ();
    }
}
System.out.printlnarray.lengthfor

Create a free account to access the full topic