import java.util.ArrayList;
import java.util.Comparator;
public class Country {
private String name;
private int size;
public Country(String name, int size) {
this.name = name;
this.size = size;
}
public String getName() {
return name;
}
public int getSize() {
return size;
}
public static void main(String[] args) {
ArrayList<Country> countries = new ArrayList<>();
countries.add(new Country("Russia", 17125191));
countries.add(new Country("Canada", 9984670));
countries.add(new Country("China", 9596960));
countries.add(new Country("United States", 9372610));
countries.add(new Country("Brazil", 8515767));
countries.add(new Country("Australia", 7692024));
countries.add(new Country("India", 3287263));
// Sort the countries in decreasing order of size
countries.sort(new Comparator<Country>() {
@Override
public int compare(Country c1, Country c2) {
return c2.getSize() - c1.getSize();
}
});
// Print the sorted list of countries
for (Country country : countries) {
System.out.println(country.getName() + " (" + country.getSize() + ")");
}
}
}