Give The Final Contents Of The Array A After The Code Below Is Executed What Is

Give the final contents of the array, a, after the code below is executed. What is the difference between “a.length” and “a[i].length”?  

int[][] a = new int[3][3];

for (int i=0; i < a.length; i++) {

 for (int j=0; j < a[i].length; j++) {

if (i != j) {

           a[i][j] = 0;

    }

    else {

           a[i][j] = 1;

    }

 }

}

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply