I am a beginner in Java and I was working on ArrayList. On a project I have a list of students . I want to create an Array list for each of these students. It's easy when you know exactly the number of students. But in that case we are not able to know the number exactly.
I have made a loop that is taking one by one all the parameters of each students. I was wondering if maybe we could create an arrayList "automatically" by just changing the name of it ? Like : (ive called x a list of word for exemple).
for(int i =o;i<x.length;i++){
ArrayList<Matiere>x[i] = new ArrayList<>();
}
The loop will be executed the number of times there are students and it will create an arraylist for each without me implementing them one by one. But it's not working. Do you have any ideas ?
Thanks !
Studentclass that encapsulates all data that belongs to a student and defines its relationships. So if every Student should have anArrayListas an attribute then thatArrayListshould be defined as a (non-static) field in the student class.