+ 1

The index to acces elements of this multidimensional array doesn t make sense to me

it s nothing like what s in the lesson before it seems conflicting to me https://www.sololearn.com/learn/Java/2149/

28th Dec 2017, 9:46 PM
Hamed
Hamed - avatar
14 odpowiedzi
+ 8
Using two indexes works like this: sample is an array with 2 elements: {1, 2, 3}, and {4, 5, 6}. The first index selects which array in sample you're accessing. Ex: sample[0] selects {1, 2, 3} The second index selects the element from the array you just chose. Ex: sample [0][1] selects 2 from {1, 2, 3}
28th Dec 2017, 10:24 PM
Tamra
Tamra - avatar
+ 8
omg I'm sorry I didn't notice what you were asking! (I think I'm just tired lol). This is something lots of people get stuck on, so I kinda jumped to conclusions. The example demonstrates setting values to elements, and getting them. The first line (that you showed) shows how to assign a new value to an element. The other line shows how to get a value out of the array. I think what was confusing is that one is an assignment: myArr[0][1] = 42; and the other has a comment saying what it contains: int x = myArr[1][0]; //4
29th Dec 2017, 12:37 AM
Tamra
Tamra - avatar
+ 8
Check your spam first. Ifyou didn't get an email, go to the ... menu in the corner > Settings > Edit Profile and change your email to something else and back to the one you want. It'll resend. Have fun here! <3 And sorry I wasn't being helpful with your question lol
29th Dec 2017, 12:41 AM
Tamra
Tamra - avatar
+ 7
Oh, sorry! This line from the lesson example replaces 3 in {1, 2, 3} with 42: myArr[0][2] = 42; The result is that myArr[0] becomes {1, 2, 42}.
28th Dec 2017, 11:05 PM
Tamra
Tamra - avatar
+ 2
it s not the first page it s clear it the second check again
28th Dec 2017, 10:36 PM
Hamed
Hamed - avatar
+ 2
int myarr[ ] [ ]={1,2,3},{4},,{5,6,7}; myarr[0][1]=42
28th Dec 2017, 10:46 PM
Hamed
Hamed - avatar
+ 2
ow lol that s simple
28th Dec 2017, 11:08 PM
Hamed
Hamed - avatar
+ 2
let me check
28th Dec 2017, 11:08 PM
Hamed
Hamed - avatar
+ 2
Tamara thanks i already know that i did from the start but that s not what i was looking for i guess the confusing detail i m asking about on the second page is something that we re not supposed to pay attention and people who focus too much like me get confused for being skeptical and checking all
28th Dec 2017, 11:57 PM
Hamed
Hamed - avatar
+ 2
anyway they didn t test us on it some guy told me it s a change in the array reassigning values to element of that index
28th Dec 2017, 11:59 PM
Hamed
Hamed - avatar
+ 2
int myarr[ ] [ ]={1,2,3},{4},,{5,6,7}; myarr[0][1]=42
28th Dec 2017, 11:59 PM
Hamed
Hamed - avatar
+ 2
that's the only thing that makes sense i guess
28th Dec 2017, 11:59 PM
Hamed
Hamed - avatar
+ 2
i can get the option to verify my account with email .Do you know how i could fix this and is it possible to get some friends here to help each other learn and make it fun
29th Dec 2017, 12:35 AM
Hamed
Hamed - avatar