0

What could be wrong?

public void getWinner () { int max = Collections.max(players.values()); for (Map.Entry<String, Interfer<entry: players.entrySet(){ if (entry.getValue().equals(max)){ System.out.print(entry.getKey()); } }

30th Apr 2022, 6:38 PM
Micheal Mfon
Micheal Mfon - avatar
2 ответов
+ 3
typo in Integer and < //for (Map.Entry<String, Interfer<entry: // players.entrySet() { for (Map.Entry<String, Integer> entry: players.entrySet() {
1st May 2022, 2:38 AM
zemiak
0
import java.util.*; import java.util.HashSet ; 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 () { int max = Collections.max(players.values()); for(Map.Entry<String, Integer>entry: players.entrySet()){ if (entry.getValue().equals(max)) { System.out.print(entry.getKey()); } } } } public class Program { public static void main(String[ ] args) { Bowling game = new Bowling(); Scanner sc = new Scanner(System.in); int gameSize=0; for(int i=0;i<3;i++) { String input = sc.nextLine(); String[] values = input.split(" "); String name = values[0]; int points = Integer.parseInt(values[1]); game.addPlayer(name, points); } gameSize=gam
1st May 2022, 8:48 AM
Micheal Mfon
Micheal Mfon - avatar