Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132930 views
License: OTHER
1
import java.util.ArrayList;
2
import java.util.Collections;
3
import java.util.List;
4
5
public class Main {
6
public static void main(String[] args) {
7
List<Country> europe = new ArrayList<Country>();
8
europe.add(new Country(81903000,357121.41,"Germany"));
9
europe.add(new Country(64667000,668763, "France"));
10
europe.add(new Country( 4985900,385199, "Norway"));
11
europe.add(new Country( 9514406,450295, "Sweden"));
12
europe.add(new Country(47212990,504645, "Spain"));
13
europe.add(new Country( 8014000, 41285, "Switzerland"));
14
europe.add(new Country( 36371, 2.02, "Monaco"));
15
System.out.println(europe);
16
Collections.sort(europe);
17
System.out.println(europe);
18
Collections.sort(europe, new PopulationDensityComperator());
19
System.out.println(europe);
20
}
21
}
22
23