Map.get
which could be replaced with getOrDefault
, computeIfAbsent
or
putIfAbsent
.
aValue = map.get(aKey); if (aValue == null) { aValue = "none"; }
List<String> list = map.get(key); if (list == null) { list = new ArrayList<>(); map.put(key, list); }
String val = map.get(key); if (val == null) { map.put(key, newVal); }
Integer val = map.get(key); if (val == null) { map.put(key, 1); } else { map.put(key, val + 1); }
This inspection is available since Java 8 only.
New in 2016.3