Iteration through hashmap | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
- 1

Iteration through hashmap

Hey guys, i just try to complete last project java, iteration through hashmap. But i still dont get it, please help https://code.sololearn.com/cla8XY9pTV1r/?ref=app

6th Mar 2021, 2:26 PM
Semmy Rajita
Semmy Rajita - avatar
2 Respostas
0
a lazy fix, you can save the max value each time you loop. with that condition maxEntry will be updated only when there's a new max value. cast entry.getValue() to int for the comparison to work. int mxv = 0; for (Map.Entry entry : players.entrySet()){ if ( (int)entry.getValue() > mxv){ maxEntry = entry; mxv = (int)entry.getValue(); } System.out.println(maxEntry.getKey()); }
6th Mar 2021, 2:57 PM
Bahhaāµ£
Bahhaāµ£ - avatar
+ 1
BahhašŸ§ i get it, thanks for explaination šŸ‘šŸ¼
7th Mar 2021, 4:57 PM
Semmy Rajita
Semmy Rajita - avatar