Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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;
  }

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Compare #integers #java #sort
ADD COMMENT
Topic
Name
3+1 =