What happened in this 42 number example in discription | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What happened in this 42 number example in discription

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); } }

2nd Jan 2021, 2:46 PM
Shubham Mishra
Shubham Mishra - avatar
2 Answers
+ 2
42 replaced 3 in the array Before: { {1, 2, 3}, {4}, {5, 6, 7} } After: { {1, 2, 42}, {4}, {5, 6, 7} } myArr[0][2] means the third element(3) of the first element of myArr ({1, 2, 3}).
2nd Jan 2021, 2:51 PM
noteve
noteve - avatar
+ 1
Thanks
2nd Jan 2021, 2:52 PM
Shubham Mishra
Shubham Mishra - avatar