!--a11y-->
Object
Creation 
Only create objects if they are really required to avoid unnecessary use of CPU time and memory.
The code sample creates the objects ArrayList, HashMap and String although, depending on the value of addToList, they might not be required.
private Object addIt(Provider p, boolean addToList){
List list = new ArrayList();
Map map = new HashMap();
String value = p.getValue();
String key = p.getKey();
if(addToList){
list.add(key);
return list;
}else{
map.put(key,value);
return map;
}
}
The code sample creates the objects ArrayList, HashMap and String when it is certain that they are actually required, thus avoiding the unnecessary creation of objects.
private Object addIt(Provider p, boolean addToList){
Object result = null;
String key = p.getKey();
if(addToList){
List list = new ArrayList();
list.add(key);
result = list;
}else{
Map map = new HashMap();
String value = p.getValue();
map.put(key,value);
result = map;
}
return result;
}