The task is to ask for a definitions of some random cards. After I introduce the cards and I access this method, the value corresponding to the key is present and it still returns null.
pair.get(a) always printing null
public static void ask() {
System.out.println("How many times to ask?");
int ask = scan.nextInt();
scan.nextLine();
Random random = new Random();
Object[] values = pair.keySet().toArray();
int retur = random.nextInt(values.length);
int i = 0;
for (String iterator : pair.keySet()) {
if (i <= ask) {
System.out.println("Print the definition of \"" + values[retur] + "\":");
String a = scan.nextLine();
System.out.println(a.equals(pair.get(values[retur])) ? "Correct answer." :
"Wrong answer. The correct one is \"" + pair.get(values[retur]) +
"\", you've just written the definition of \"" + pair.get(a) + "\".");
}else
break;
}