Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 786
  • Last Modified:

Accessing items in ArrayList of ArrayLists

Hi

I have an ArrayList (al) and I add Arraylists to it.
Is there a simple way to get the first item of the first arraylist?
Or the sixth item of the first arraylist?
thanks
HMC
0
hmcgeehan
Asked:
hmcgeehan
1 Solution
 
BogdyPtrCommented:
Try ((ArrayList)al[0])[0] to get first element of the first ArrayList.
A more elegant solution is to use generic List class instead of the main array list:

List<ArrayList> arrays;

...

arrays[1][2] = 5;
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now