+ 1
Explain Please!
I am learning Java. I got this example- 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); } } I removed the line- " myArr[0][2] = 42;" and nothing changed. The result was still 4. Can anyone tell me what this line is doing here?
4 Respuestas
+ 10
The statement myArr[0][2] = 42 makes the array elements:
{ {1, 2, 42}, {4}, {5, 6, 7} }
That means the element at row 0 and column 2 has been changed to 42.
Note: array index starts at 0
If you print myArr[0][2], you'll see 42 instead of 3.
Similar post: https://www.sololearn.com/Discuss/880787/why-this-myarr-0-2-42-is-used-in-this-program
+ 4
@SchoolWeb,
You may communicate with other SL members via this Discord channel:
https://www.sololearn.com/discuss/689391/?ref=app
+ 2
Oh..Now i understand. Thanks
+ 1
[Off-Topics]
how to contact with any sololearn user to learning personal things....?
Please, help me