Skip to content

Instantly share code, notes, and snippets.

@MericBERBER
Created June 6, 2017 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MericBERBER/fadeaa3a1d7319eab027b0c4b4b403e0 to your computer and use it in GitHub Desktop.
Save MericBERBER/fadeaa3a1d7319eab027b0c4b4b403e0 to your computer and use it in GitHub Desktop.
public class TestComparator {
public static void main(String args[]){
Person p1 = new Person("Meric",25);
Person p2 = new Person("Ali",15);
Person older = older(p1,p2, new PersonComparator());
System.out.println("Yasi buyuk olan person :" + older.isim); // Meric
}
public static Person older(Person p1, Person p2, PersonComparator c){
return c.compare(p1,p2) > 0 ? p1 : p2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment