As the title says, I am currently implementing the below code (well about to), is their a better way - as this seems a bit nasty.
Map<Integer, List<Objects>> allObjectsMap = newHashMap(); //guava
for(int i=1:i<myVar:i++){
Map<Integer, Objects> eachObjectMap = getMyObjectMap(i);
for(Map.Entry<Integer, Object> entry:eachObjectMap.entrySet()){
List objectList = allObjectsMap.get(entry.getKey())
if(objectList == null){//will be null the first time
objectList = newArrayList();//guava
objectList.add(entry.getValue());
allObjectsMap.put(entry.getKey(),objectList);
}
else{
objectList.add(entry.getValue());
}
}
}
Thanks!