Iterator .
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Stack{
public static void main(String[] args){
HashMap<Integer, String> map = new HashMap<Integer,String>();
for(int i = 0; i < 8;i++){
map.put(i, "OUT-GAME");
}
map.put(8, "IN-GAME");
map.put(9, "IN-GAME");
Iterator it = map.entrySet().iterator();
int check = 0;
while(it.hasNext()){
Map.Entry pair = (Map.Entry<Integer,String>) it.next();
System.out.println(pair.getKey() + " " + pair.getValue());
if(pair.getValue().equals("IN-GAME")){
System.out.println("We have a player in game");
check++;
}
if(check > 1){
System.out.println("More than 1 player in game. There something wrong");
}
}
if(check == 1){
System.out.println("We have exactly one player in the game");
}
}
}
, "in-game".