1  import java.util.Set;
  2  import java.util.TreeSet;
  3  
  4  /**
  5     This program tests a tree set with a class that implements the Comparable interface.
  6  */
  7  public class TreeSetDemo
  8  {
  9     public static void main(String[] args)
 10     {
 11        Country country1 = new Country("Uruguay", 176220);
 12        Country country2 = new Country("Thailand", 514000);
 13        Country country3 = new Country("Belgium", 30510);
 14  
 15        Set<Country> countries = new TreeSet<Country>();
 16  
 17        countries.add(country1);
 18        countries.add(country2);
 19        countries.add(country3);
 20        countries.add(country1); // Has no effect
 21        countries.remove(country3); 
 22        countries.remove(country3); // Has no effect
 23        countries.add(country3);
 24  
 25        System.out.println(countries);
 26     }
 27  }