I fetched some data from DB using and stored it in a list as below:
List<MyObject> list =new ArrayList<MyObject>();
list contains 2 MyObject class's objects.
I have 2 Map implementations:
Map<String,Map<String,Long>> map1 = new HashMap<String,Map<String,Long>>();
Map<String,Long> map2 = new HashMap<String,Long>();
I iterated the list and did the following code
for(myObjectObj : list){
map2.put(myObjectObj.getAction(),myObjectObj.getCount());
map1.put(myObjectObj.getName(),map2);
}
Final output i wanted was map1 in the following way :
Name1 action1 count1
action2 count2
Name2 action3 count3
action4 count4
but with my code i am not getting the desired output.