1  import java.util.*;
  2  
  3  public class ComparatorTester
  4  {
  5     public static void main(String[] args)
  6     {
  7        ArrayList<Country> countries = new ArrayList<>();
  8        countries.add(new Country("Uruguay", 176220));
  9        countries.add(new Country("Thailand", 514000));
 10        countries.add(new Country("Belgium", 30510));
 11        Comparator<Country>  comp = new CountryComparatorByName();
 12        Collections.sort(countries, comp);
 13           // Now the array list is sorted by country name
 14        for (Country c : countries)
 15          System.out.println(c.getName() + " " + c.getArea());
 16     }
 17  }
 18