I have the following nested Map
defined in my class:
private Map<String, Map<String, String>> messagesByFactTypeAndCategory;
public void setMessagesByFactTypeAndCategory(Map<String, Map<String, String>> messagesByFactTypeAndCategory) {
this.messagesByFactTypeAndCategory = messagesByFactTypeAndCategory;
}
public Map<String, Map<String, String>> getMessagesByFactTypeAndCategory() {
if (messagesByFactTypeAndCategory == null) {
return Maps.newHashMap();
}
return messagesByFactTypeAndCategory;
}
I'm trying but unable to traverse the messagesByFactTypeAndCategory
map and get the data inside this to display in console.
Below is the code that I tried so far:
Map<String, Map<String, String>> newMap = executionResult.getMessagesByFactTypeAndCategory();
Set set = newMap.entrySet();
Iterator iterator = set.iterator();
while(iterator.hasNext()) {
Map.Entry mentry = (Map.Entry)iterator.next();
System.out.print("key is: "+ mentry.getKey() + " & Value is: ");
System.out.println(mentry.getValue());
}
Any help is appreciated!