I have 2 classes, ‘students’ and ‘lesson’.
I am trying to have students as a class storing basic data such as their name and age. I want to have a listarray in the lesson class that holds the students objects so that they can be looped through.
Here is the listarray code within my lesson class
List<Students> studentlist = new ArrayList<Students>();
I have then been using this code to create a new object in the students class
Students G = new Students("Tom",15 );
I’m still learning Java but I assume the list needs this adding to it directly rather than creating a member like this. How do I accomplish this so that the listarray stores the objects.