*Disclaimer: I am a super noob in java so bear with me.
I have a arraylist called hw_list that contains strings that were read in from a file like so:
[Doe John 1 10 1 Introduction.java, Doe Jane 1 11 1 Introduction.java, Smith Sam 2 15 2 Introduction.java Test.java]
I was able to make each element of the array it's own sublist so it prints like so:
[Doe John 1 10 1 Introduction.java]
[Doe Jane 1 11 1 Introduction.java]
[Smith Sam 2 15 2 Introduction.java Test.java]
But to split each element into it's own sublist like above, I have to manually write each sublist out like:
List<String> student1 = hw_list.subList(0, 1);
List<String> student2 = hw_list.subList(1, 2);
List<String> student3 = hw_list.subList(2, 3);
My problem is that the number of string that are read in can change so I don't know how many sublists to make ahead of time.
Is there a way to dynamically create new lists using a loop and then splitting each element based on hw_list.size()?
Is something sort of like this possible:
for(int i=0; i<hw_list.size(); i++){
List<String> student(i) = hw_list.sublist(i, i+1)
}
TL;DR
How do I get a loop to create a new list for every element of an array?