- Map.putIfAbsent method could be used to replace the code like this:
if (!map.containsKey(aKey)) {
map.put(aKey, aValue);
}
- Map.getOrDefault method could be used to replace the code like this:
aValue = map.get(aKey);
if (aValue == null) {
aValue = "none";
}
- Map.computeIfAbsent method could be used to replace the code like this:
List<String> list = map.get(key);
if (list == null) {
list = new ArrayList<>();
map.put(key, list);
}
- List.sort instance method could be used to replace Collections.sort static method