티스토리 뷰

public static void main(String[] args) {

    List<Student> studentList = new ArrayList<>();
    studentList.add(new Student("Pea", 20));
    studentList.add(new Student("Ni", 35));
    studentList.add(new Student("Pang", 30));
    studentList.add(new Student("Tum", 25));
    studentList.add(new Student("Sombut", 22));
    
    Student student =  Collections.max(studentList, Comparator.comparing(s -> s.getAge()));
    System.out.println("The older student is : " + student.getName());
    
    student =  Collections.min(studentList, Comparator.comparing(s -> s.getAge()));
    System.out.println("The youngest student is : " + student.getName());


}

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함