Answers for "Compare integers java sort"

0

Compare integers java sort

public class AgeComparatorDesc implements Comparator<Student> {

  @Override
  public int compare(Student o1, Student o2) {
    if (o1.age > o2.age) {
        return -1;
    } else if (o1.age < o2.age) {
        return 1;
    }    
     return 0;
  }

}
Posted by: Guest on May-18-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language