001package horstmann.ch04_sort3;
002import java.util.ArrayList;
003import java.util.Collections;
004
005public class ComparatorTester
006{
007        public static void main(String[] args)
008        {
009                ArrayList<Country> countries = new ArrayList<Country>();
010                countries.add(new Country("Uruguay", 176220));
011                countries.add(new Country("Thailand", 514000));
012                countries.add(new Country("Belgium", 30510));
013
014                Collections.sort(countries, (country1, country2) -> country1.getName()
015                                .compareTo(country2.getName()));
016
017                // Now the array list is sorted by name
018                for (Country c : countries)
019                        System.out.println(c.getName() + " " + c.getArea());
020        }
021}
022