+ 1

what is that myArr[0][2]=42

28th Aug 2016, 7:07 AM
Ahamed Shah
Ahamed Shah - avatar
11 Answers
+ 2
assign a new value in mrArr[0][2]=42
28th Aug 2016, 10:25 AM
Mohammed Danish
Mohammed Danish - avatar
+ 1
int [][] my_arr = {{0,1,2},{3,4,5}}; /*{0,1,2} is a row, {3,4,5} is another row so imagen it like this : {0,1,2} first row its row number 0 . {3,4,5} the second row its row number 1 . rows are written in the first square brackets . .............. columns are written in the second square bracket .*/ int x = myarr [1][0]; /* [1] is the row {3,4,5} [0] means the number 3 (the first number in row 1 ) so its called column .*/ system.out.println(x);
28th Aug 2016, 7:51 AM
Mohammed Ghaith AL-Mahdawi
Mohammed Ghaith AL-Mahdawi - avatar
+ 1
thanks :)
28th Aug 2016, 10:27 AM
Ahamed Shah
Ahamed Shah - avatar
+ 1
That 42 is you are assigning to the array element in 0th row 2nd column. But actually we have 3 in the program. That 3 is replaced by 42 when you want to see the element in myArr[0][2]
13th Sep 2016, 2:23 PM
Pavankumar Reddy Nadiminti
0
what is that 42?
28th Aug 2016, 7:54 AM
Ahamed Shah
Ahamed Shah - avatar
0
output in my code will be //3
28th Aug 2016, 7:58 AM
Mohammed Ghaith AL-Mahdawi
Mohammed Ghaith AL-Mahdawi - avatar
0
that 42 is from a code its like mine but dfrnt Num. !
28th Aug 2016, 7:59 AM
Mohammed Ghaith AL-Mahdawi
Mohammed Ghaith AL-Mahdawi - avatar
0
public class Program { public static void main(String[] args) { int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} }; myArr[0][2] = 42; int x = myArr[1][0]; System.out.println(x); } } can u explain in this scenario..what is that 42?
28th Aug 2016, 8:18 AM
Ahamed Shah
Ahamed Shah - avatar
0
welcome
28th Aug 2016, 10:28 AM
Mohammed Danish
Mohammed Danish - avatar
0
@Ahamad shah so your x = 4
19th Jan 2017, 12:26 AM
Scorpion Fox
Scorpion Fox - avatar
0
No one is really answering the question which is what is that "42" doing there!?
25th Apr 2017, 2:54 PM
Giovanny Florez
Giovanny Florez - avatar