- 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.. ??

16th Jul 2017, 12:08 PM
Himanshu Patel
Himanshu Patel - avatar
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 :)
16th Jul 2017, 12:19 PM
D_Stark
D_Stark - avatar
+ 2
8
22nd May 2020, 10:58 PM
javlonbek shoyimqulov
javlonbek shoyimqulov - avatar
+ 1
you can imagine this as an 3×5 table. 0 and 2 select the row and column.
16th Jul 2017, 12:19 PM
Farshad
Farshad - avatar
+ 1
I need help two this does not made sence?
8th Jan 2021, 5:52 PM
Henry Mauer
Henry Mauer - avatar
+ 1
wefgsdfgsdfg
8th Jan 2021, 5:53 PM
Henry Mauer
Henry Mauer - avatar
0
8
11th Jun 2020, 4:17 AM
chathura jayawardhana
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
9th Jan 2021, 1:42 AM
D_Stark
D_Stark - avatar
0
8
7th May 2022, 11:08 AM
U.L.F. Feroza