01: import java.util.*;
02: 
03: public class CountrySortTest
04: {
05:    public static void main(String[] args)
06:    {
07:       ArrayList countries = new ArrayList();
08:       countries.add(new Country("Uruguay", 176220));
09:       countries.add(new Country("Thailand", 514000));
10:       countries.add(new Country("Belgium", 30510));
11:       Collections.sort(countries); 
12:          // now the array list is sorted by area
13:       for (int i = 0; i < countries.size(); i++)
14:       {
15:          Country c = (Country) countries.get(i);
16:          System.out.println(c.getName() + " " + c.getArea());
17:       }
18:    }
19: }
20: