user2097804 user2097804 - 1 year ago 103
Java Question

Two Dimensional ArrayList

I know that I can add a dimension to an array by adding another [] beside it. But can I have more than one Dimension in a java.util.ArrayList? How might I accomplish this?

Answer Source

Yes, it's possible. Just have the elements of your ArrayList also be ArrayLists.

ArrayList<ArrayList<Integer>> twoDArrayList = new ArrayList<ArrayList<Integer>>();

This would work with not just ArrayLists, but other collection types as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download