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

5th May 2020, 11:48 PM
Zoe
Zoe - avatar
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);
6th May 2020, 12:38 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
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
6th May 2020, 3:46 AM
Zoe
Zoe - avatar