hi im trying to access a MultiValueMap which is in a Hashmap
this is my HashMap insideprojectDetails
HashMap
private HashMap<String, ClassDetails> classDetailsMap = new HashMap<String, ClassDetails>();
inside that classDetailsMap
i have MultiValueMap
called methodDetailsMap
private MultiMap<String, MethodDetails> methodDetailsMap = new MultiValueMap<String, MethodDetails>();
when im trying to access the methodDetailsMap
by
Set<String> methodNamesSet = projectDetails.getClassDetailsMap().get(cls).getMethodDetailsMap().keySet();
String[] methodNames = methodNamesSet.toArray(new String[0]);
for (int i = 0; i < methodNames.length; i++) {
String methodName = methodNames[i];
System.out.println(cls + " "+methodName);
//codes used to access key values
Collection coll = (Collection) methodNamesSet.get(methodName);
System.out.println(cls + " "+methodNamesSet.get(methodName));
}
i get a error get
saying cannot resolve method get(java.lang.String)
is there any way to access the MultiValueMap
2
Answers
I read your code and as I understand first you need to get all method names of
cls
class then you want to get them one by one. So in the for loop you need toget
from thegetMethodDetailsMap()
.This will help you:Its a compilation error with your code. There is no get method in Set.
To get method details, first loop through the set and then get method details from methodDetailsMap as below.