+ 3
Array list
How can I store large data in arrays?? Like I am writing a code for student grades management system..so how can I store info(name, id, age, grades, course enrolled) of student in array list?
3 Respostas
+ 8
Basically you need to create the student object
and then you add that object with all the attributes to your list like
List<Student> students = new ArrayList();
students.add(student1);
If you need to handle many records, reading the students from a file or a database would be the better solution than creating them one by one.
+ 4
or
List<Student> students = new ArrayList<>();
if you dont like warnings
+ 2
Class Students {
private String name;
Private int age;
private String grade;
public Students (String name,int age, String grade){
this.name=name;
this.age=age;
this.grade=grade;
}
//get and setters.
}
Main {
Students student0= new Students("Jack",19,"Higschool")
ArrayList <Students> Class= new ArrayList();
Class.add(student0)
}
// I am not a expert, hope it works for someone.