I have a nested LinkedHashMap that looks like this:
LinkedHashMap<String,LinkedHashMap<String,LinkedList<Long>>> map = new...
The issue is that only 1 inner map is added per outer map, whereas I am expecting 2. I think the problem is how I'm constructing my map, and over-writing the first inner map with the second. (To briefly summarize my program, I am mapping each hand onto each finger. The mapping structure needs to be Finger={Right_Hand=[],Left_Hand=[], not vice versa.)
The constructor:
Set<String> handNames = new HashSet<String>(Arrays.asList("Left","Right");
Set<String> fingerNames = new HashSet<String>(Arrays.asList("Pinky","Ring","Middle","Index","Thumb");
LinkedHashMap<String, LinkedHashMap<String,LinkedList<Long>>> fingerHandMap = new LinkedHashMap<String, LinkedHashMap<String,LinkedList<Long>>>();
createNestedMap() {
for (String finger : fingerNames)
for (String hand : handNames) {
LinkedHashMap<String, LinkedList<Long>> handMap = new LinkedHashMap<String, LinkedList<Long>>();
handMap.put(hand, new LinkedList<Long>());
fingerHandMap.put(finger, handMap);
}
}
When I print out the map, though, it looks like this:
{Ring={Left=[]}, Pinky={Left=[]}, Thumb={Left=[]}, Middle={Left=[]}, Index={Left=[]}}
How would I go about creating unique LinkedLists, to allow the map to look like:
{Ring={Right=[], Left=[]}, Pinky={Right=[], Left=[]}, Thumb={Right=[], Left=[]}, Middle={Right=[], Left=[]}, Index={Right=[], Left=[]}}
Thanks!