Java using Map.Entry over a Map not compiling -
i getting error cannot seem fix myself, might stupid error, unable see it.
map<templatebean, map<string, string>> templatemap = new hashmap<>(); //some code fills map int biggestsize = 0; map<string, string> biggestvalues = null; (map.entry<templatebean, map<string, string>> entry : templatemap.values()) { map<string, string> currentvalues = entry.getvalue(); int currentsize = currentvalues.size(); if (currentsize > biggestsize) { biggestsize = currentsize; biggestvalues = currentvalues; } } if (biggestvalues != null) { values = biggestvalues; }
it giving error on for-loop:
incompatible types required: entry<templatebean,map<string,string>> found: map<string,string>
however pretty sure got correct, i'm not new iterating on maps or anything, still tuesday morning.
regards.
change line -
for (map.entry<templatebean, map<string, string>> entry: templatemap.values())
to -
for (map.entry<templatebean, map<string, string>> entry: templatemap.entryset())
check out javadoc.
Comments
Post a Comment