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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -