I have a Map in my code, where I\'d avoid potential null pointers if the map\'s #get() method returned an empty l
Similar to previous posts except you can just override the get method if you want to change its behaviour.
Map> map = new LinkedHashMap>() {
public String get(Object key) {
List list = super.get(key);
if (list == null && key instanceof String)
super.put(key, list = new ArrayList());
return list;
}
};