I have a map like this:
private Map<String, List<List<String>>> someMap;
private List<List<String>> someList1;
private List<String> someList2;
....Some initialization..... ....Some list population....
Then I have,
if(someMap.get(someKey) == null){
someList1.add(someList2);
someMap.put(someKey, someList1);
} else {
someMap.get(someKey).add(someList2);
}
Note that the list gets clear after adding to the map and gets populated afterward.
For instance, I have two keys "Apple" and "Orange" with some values. After the loop, I get only Orange. The previous key gets overridden!!!
EDIT: In every iteration of a loop, a list gets populated. End of the loop, it gets added to the map and after adding, the list gets clear().
Any advice? Thanks.
CODE: http://pastebin.com/m2712e04 [On request.. so please don't blame me for posting it..]