X403: Write A Comparator 2

For this question, we will be sorting Person objects. Here is the Person class so you’ll know what you have available:

public class Person{



    private int age;
    private String name;
    private String grade;

    public Person(int a, String n, String gr) {
        age = a;
        name = n;
        grade = gr;
    }


    public int getAge() {
        return age;
    }


    public String getGrade() {
        return grade;
    }

}

For this question implement a compare method that will sort people by age from youngest (lowest age) to oldest (highest).

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.