Give the final contents of the array a after the code below


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;
}
}
}

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Give the final contents of the array a after the code below
Reference No:- TGS02383006

Now Priced at $10 (50% Discount)

Recommended (94%)

Rated (4.6/5)