I use a variable class which stores an integer. If the integer is 13, I need 13 arraylists to be created. Any idea as to how I would do this?
This is what is in my while loop:
ArrayList<Integer[]> list + count = new ArrayList<>();
With the following:
ArrayList<ArrayList<Integer>> myLists = new ArrayList<ArrayList<Integer>>();
for(int i = 0; i < 4; i++) {
ArrayList<Integer> newList = new ArrayList<Integer>();
myLists.add(newList);
}
Let's say I need the integer 9 to go into the 3rd array list and the integer 3 to go to the 2nd array list. How would i do that?
+sign on the left side of an assignment? That isn't legal Java. Are you inventing your own syntax and hoping the compiler can figure it out?ArrayList(ArrayList<T>[]) or anArrayListofArrayList(ArrayList<ArrayList<T>>). I don't know whatTis. You can create an array of 13ArrayListsby sayingnew ArrayList<T>[13], but then you have to create eachArrayListin a loop, since this will be an array of nulls.ArrayList, or some other data structure. Don't do it by trying to create a large number of variables.