+ 2
I didn't understand
why myArr[0][2] =42 ?
14 Answers
+ 2
@kais hassn nobody can help you without source.
+ 2
you can see the multi dimensional array defined as
MyArr={ {1,2,3}, {4}, {5,6,7} }
as
[1] [2] [3]
[4]
[5] [6] [7]
so if you check the content of MyArr[1][0] you're checking the content of the first column (0) of the second row(1), thus 4.
in java a matrix doesn't need to have the same column number per row. that takes the name of jagged matrix
+ 2
you might want to reformulate the question, It's quite difficult to understand what's the matter right now.
if you go
arr[0][2] = 42;
and then
System. out. print(arr[0][2]) ;
you will get 42
+ 2
you're welcome :) try to be more complete when asking a question in the first place: you'll get better answers if we can properly understand what is your problem đ
+ 1
what do you want know
+ 1
you'll have to provide more of your code for us to help you
+ 1
and whats wrong with it ?
+ 1
think about it as an insert.
+ 1
thank youâ€
+ 1
sure
0
i removed it from the code and the code still work and show 4 as result
0
this is the code...
int[ ][ ] myArr = { {1, 2, 3}, {4}, {5, 6, 7} };
myArr[0][2] = 42;
int x = myArr[1][0];
// 4
0
i don't understand why they put"myArr[0][2]=42"
0
i understand this but myArr[0][2] not equal to 42 and i removed it and the code still work