How do I get the code below to repeat the command, where the players name already exists in the key set?
public static Map<String, Player> players = new TreeMap<>();
for (int loop = 1; loop <= 4; loop++) {
System.out.println("enter player"+loop+"s name");
name = scanner.next();
if(players.keySet().contains(name)) {
System.out.println("name in use - enter new name");
}else {
players.put(name, new Player());
}
}