Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public static void main(String[] args){
  2. Person p1 = new Person("George");
  3. Person p2 = new Person("Ion");
  4. Person p3 = new Person("Zatreanu");
  5. Person.PersonComparator comp = new Person.PersonComparator();
  6. ArrayList<Person> lista = new ArrayList<Person>();
  7. lista.add(p1);
  8. lista.add(p3);
  9. lista.add(p2);
  10. Collections.sort(lista, comp);
  11. for(int i = 0; i < 3; i++){
  12. System.out.println(lista.get(i).getName());
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement