Search
 
SCRIPT & CODE EXAMPLE
 

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

}
Comment

PREVIOUS NEXT
Code Example
Java :: java bigdecimal 
Java :: program to check if the given date is in in the format dd/mm/yyyy java 
Java :: how to use string variables with an if statement in java 
Java :: anagram java 
Java :: java string join 
Java :: print anything in java 
Java :: how to create object of abstract class in java 
Java :: what is static setter and getter examples in java 
Java :: how to initialize char in java 
Java :: how to disable screenshot in react native 
Java :: java rgb to color 
Java :: final vs static keyword in java 
Java :: java how to change the length of an array 
Java :: flutter unable to find bundled java version 
Java :: java method parameters 
Java :: java map tostring 
Java :: separateur JMenu swing java 
Java :: generate random number in java within a range without repeating with android studio 
Java :: how to pass a float between activities in android studio 
Java :: Describe Methods Overloading in Java 
Java :: pdf intent does not have permission to launch 
Java :: give ram to java 
Java :: how to call a non static method 
Java :: how to store date in java 
Java :: java empty arraylist 
Java :: border swing 
Java :: Java Hashmap Replace Elements 
Java :: pythagoras method in java 
Java :: Create EntityManager Hibernate 
Java :: java swing on close 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =