Professional Documents
Culture Documents
ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class Student {
this.id = id;
this.name = name;
this.age = age;
this.gpa = gpa;
return id;
return name;
return age;
return gpa;
@Override
public String toString() {
return "Student{" +
"id=" + id +
'}';
// Create a HashMap to store student IDs as keys and student objects as values
studentMap.put(student.getId(), student);
System.out.println(student);
// Filter students who are older than a certain age and display the filtered list
filteredStudents.add(student);
System.out.println(student);