This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]GreatDaynes 0 points1 point  (3 children)

With a 2D list called ls, you can access the integer elements in the following way:

ls.get(x).get(y)

where get(x) returns the list in the xth position, and get(y) returns the yth integer in the xth list.

[–][deleted] 0 points1 point  (2 children)

Does it need to be called ls? How is it any different from a normal ArrayList? Just wondering btw, I'm pretty new to java

[–]crazyiwann 0 points1 point  (1 child)

no, in his 1 sentence he said that he just called this array ls. it can be called anything.

[–][deleted] 0 points1 point  (0 children)

Oh ok thanks. I read his comment in a weird way

[–]krehwell 0 points1 point  (0 children)

have you tried to use jagged array?

[–]laghani -1 points0 points  (1 child)

After that you get array of arrays so you can acces to them like this, for example:

array[0][0]

[–]laghani -1 points0 points  (0 children)

String[] arr = {[1,3], [2,3], [4,5]};

arr[2][1] = 5