0
How would I create a static ArrayList that adds student objects to itself, JAVA
The list would be compiled of all the students created https://code.sololearn.com/cwZgtj8lsA5X/?ref=app
2 Réponses
+ 2
I assume you mean you wanna add this in a main nethod in an outside method.
So you write:
// This line is out of methods in the class you use the students objects you creae.
Static ArrayList <Student> students = new ArrayList <>();
Now in the main method you should create the objects.
// These lines will be inside a method.
Student student = new Student ();
Students.add (student);
0
https://photos.app.goo.gl/4cufRiL1rDTx2Ned9
https://photos.app.goo.gl/acqg1AzFgHFXYXrG8
If those links work, how would I incorporate the arraylist with the constructor