public class Student {
private String name;
private int age;
public Student(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
import com.stupid.collections.GroupedHashMap;
import java.util.List;
import java.util.Map;
public class Main {
public static void main(String[] args) {
List<Student> studentList = List.of(
);
}
}
Map<Integer, List<Student>> groupedMap = new GroupedHashMap<>(studentList, Student::getAge);
for (Map.Entry<Integer, List<Student>> entry : groupedMap.entrySet()) {
int age = entry.getKey();
List<Student> students = entry.getValue();
for (Student student : students) {
}
}