Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Collection<Country> getMostPopulatedCountries() {
- int maxPop = 0;
- Set<Country> countries = new HashSet<Country>();
- for (Country country : getAllCountries()) {
- if (country.getPopulation() == maxPop) {
- countries.add(country);
- } else {
- if (country.getPopulation() > maxPop) {
- countries.clear();
- countries.add(country);
- }
- }
- }
- return countries;
- }
Add Comment
Please, Sign In to add comment