Source of CountrySortTester.java


  1: import java.util.*;

  3: public class CountrySortTester
  4: {
  5:    public static void main(String[] args)
  6:    {
  7:       ArrayList<Country> countries = new ArrayList<Country>();
  8:       countries.add(new Country("Uruguay", 176220));
  9:       countries.add(new Country("Thailand", 514000));
 10:       countries.add(new Country("Belgium", 30510));

 12:       Collections.sort(countries);
 13:       // Now the array list is sorted by area
 14:       for (Country c : countries)
 15:          System.out.println(c.getName() + " " + c.getArea());
 16:    }
 17: }