What's wrong with my code apart from main function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong with my code apart from main function

import java.util.*; public class Bowling { HashMap<String, Integer> players; Bowling() { players = new HashMap<String, Integer>(); } public void addPlayer(String name, int p) { players.put(name, p); } public void getWinner(){         HashMap<String, Integer> hm = new HashMap<String, Integer>();         Map.Entry<String, Integer> entryWithMaxValue = null;         for (Map.Entry<String, Integer> currentEntry : hm.entrySet()) {             if (entryWithMaxValue == null || currentEntry.getValue().compareTo(entryWithMaxValue.getValue()) > 0) {                 entryWithMaxValue = currentEntry;             }                }      System.out.println(entryWithMaxValue.getKey());    }       }

25th May 2021, 11:47 AM
mangesh choudhari
mangesh choudhari - avatar
1 Answer
+ 2
what's wrong? it's incomplete ^^
25th May 2021, 11:52 AM
visph
visph - avatar