i would like to know how can I get a new map that is the reversed map of mine?
My actual Map looks like that:
centralMap = new HashMap<String, Map<String, String>>();
nestedMap = new HashMap<String, String>();
the nestedMap is just created in the put-method.. and to put an element i use the following in the main method:
TrueStringMap2D testmap = new TrueStringMap;
testmap.put("Mickey Mouse","Mathematics","1.0");
testmap.put("Mickey Mous","Physics","1.3");
testmap.put("Minnie","Chemistry","2.3");
......
now i would like to reverse the map through a method that i named “flipped()”
i want to change the Keys of the nestedMap to Keys of the centralMap, and vice-versa.. so every “subject” (like mathematics, physics, ..) will have a nestedMap of students and the grades.. how could i do that?
im not allowed to create classes in my TrueString2D.. i just need to copy perhaps the Keys of the centralMap in a list, and those of the nestedMap in another List, and then create a new map HashMap>(); (same as my centralMap) and copy the list of old keys of the nestedMap in the NEW created map (for ex. newCentralMap) as keys, and as value, i’ll copy the old keys of the centralMap in the newNestedMap and the values of the newNestedMap are the same as the ones on the old map.. but i dont know exactly how to do that, and if i can copy a list in a map :S
Thankyou verymuch
Why don’t you use
HashMap<String, Map<String, String>>()instead ofTrueStringMap2Dthe output