How the 42 comes?? | Sololearn: Learn to code for FREE!

-5

How the 42 comes??

Kindly explain a bit there are three arrays In the example and thre is 42 for what!!

4/30/2019 9:36:07 AM

GOHAR HASSAN

3 Answers

New Answer

+11

Hey, please clarify your question. It has no meaning at all.

+2

myArr[0][2] --> before changing the value --> 2 (first index for the array, second index for the value inside this array) myArr[0][2] = 42 means you change the value from 2 to 42 The array looks now:{ {1,42,3}, {4}, {5,6,7} } It is just an example how to store a number (in this case 42) at a specific position in your array.

0

In Java tutorials Chapter of Arrays Topic of Multidimentional arrays They have included three array Which are nested in curcly braces 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); } }