Use more powerful Map methods.

This commit is contained in:
Karsten Loesing 2018-08-20 15:20:36 +02:00
parent cb966bc48c
commit c5f0530e1b

View File

@ -87,11 +87,7 @@ public class News {
}
List<String> placeNames = new ArrayList<>();
for (String place : this.places) {
if (countries.containsKey(place)) {
placeNames.add(countries.get(place));
} else {
placeNames.add("Unknown Country");
}
placeNames.add(countries.getOrDefault(place, "Unknown Country"));
}
return placeNames;
}