How would I access an Integer Array inside an Arraylist, both of which are resizable?
I have this code so far:
List<Integer[]> vertices_passed = new ArrayList<Integer[]>();
And I want to go into vertices_passed and add an element to the Integer array.
Something like this:
vertices_passed.get(certain_index).set(index_of_integer_array, Integer.valueof(9))
Is there a better way to use ArrayLists to create a data structure that looks like this:
ArrayList {
[0]
[0] A
[1] B
[1]
[0] A
[1] C
[2] F
[3] G
[2]
[0] D
[1] C
[2] F
[3] G
[4] H
[3]
[0] A
[0] D
[0] I
Also- how would I add elements to the inner array?
Thanks
ArrayList<ArrayList<Integer>>?List<List<Integer>>backed byArrayList<List<Integer>>that will containArrayList<Integer>.ArrayList<ArrayList<Integer>>it simply puts more constraints on the types used. One can also use anArrayList<LinkedList<Integer>>LinkedListcan perform this in constant time worst case while anArrayListcould take linear time worst case.