+ 1
Can someone make a table (graphic presentation or explanation) for this multidimensional array...
2 odpowiedzi
+ 1
In the comments below are examples.
https://www.sololearn.com/learn/Java/2149/?ref=app
First we have rows and then columns.
The array looks like this:
1 2 3
4
5 6 7
If we want 6. We go to row 2(index started with 0) and then column 1.
so we write
int x = myArr[2][1];
+ 1
int[ ][ ] myArr = { { {1, 2, 3}, {4}, {5, 6, 7} };
myArr[0]=> {1, 2, 3},
myArr[1]=> {4},
myArr[2] => {5, 6, 7} ;
myArr[0][0] = 1;
myArr[0][1] = 2;
myArr[0][2] = 3;
similar way for remaining...
you reassigning here
myArr[0][2] = 42;
int x = myArr[1][0]; //{4}'s value at index 0
System.out.println(x);