- 2
What is the output of this code? int array[ ][ ] = {{3, 5, 8}, {7, 54, 1, 12, 4}}; System.out.println(array[0][2]);
What is the output of this code? int array[ ][ ] = {{3, 5, 8}, {7, 54, 1, 12, 4}}; System.out.println(array[0][2]); i knew answer is 8 but i how is it .. anybody will explain me.. ??
8 Respostas
+ 4
you have 2 array blocks
1st array block is [0]<block[0]<number = 3
2nd array block is [1]<block[0]<number = 7
if i was to do both end numbers in each array block it would look like this
1st block is [0]<block[2]<number = 8
2nd block is [1]<block[4]<number = 4
java counts each array block and array number starting with 0 then 1
so basicly 0 is 1 strange but it makes it easier for java :)
+ 2
8
+ 1
you can imagine this as an 3Ă5 table.
0 and 2 select the row and column.
+ 1
I need help two this does not made sence?
+ 1
wefgsdfgsdfg
0
8
0
Henry Mauer Imagin having 2 people holding n amount of fruit in a particular order apple,pear,pineapple ect ect
We have 2 blocks like so which represents the index of each array of elements also remeber computers count form 0 unlike us were we start counting from 1 2 3 ect ect
1 2
| |
\/ \/
[] []
Block 1 is the person your selecting
Block 2 is the fruit that person is holding
So let's say person 1 is holding 3 fruit in the particular order above
[0] = Person 1 ( array 1)
[1]= fruit index at 2 which is a pearđ§đ (elements) so...
[1][2] would be person 2 holding a pineapple đ§đ
đ hope that helps
0
8