I just saw this code on the web and can't think of what array of 'b' would be.
int[][] a = {{4,2},{3,6,8}};
int[] b = a[1]
b[0] = 5;
The int array a is a 2D array which consists of two 1-D arrays: [4,2] and [3,6,8].
We have then initialised a 1D array referred to as 'b' which has been set to the second (1-index) array of a.
Therefore b = [3,6,8]. 'b' refers to the first 1D array in 'a'.
You finally set the 0th index of b's array to be 5. b[0]=5
This means b has now become b=[5,6,8]
Well, a two dimensional array has both a row and a column
In this case, a[1] is asking for the second row of a. Remember that index begins at 0.
So, the second row of a would be {3,6,8}.
Therefore b = a[1] evaluates to b = {3,6,8}
Then, b[0] is accessing the first index of b, which is 3 and changing it to 5. So the end result is {5,6,8}.
a is a two dimension array, Inorder to access a case in that array you need two index variables,..think of it as matrix... There is line and column to store the variables or you can think of ot like array of arrays.. So at first b = {3,6,8} because a[1] is the second array, then you modified the forst element in b, so b ={5,6,8}
b?