for (int i = 0; i < players.length; i++) {
for (int j = 0; j < 2; j++) {
if (j == 0) {
System.out.println("Player " + (i + 1) + "'s first card is:");
}
else {
System.out.println("Player " + (i + 1) + "'s second card is:");
}
players[i][j] = sc.nextLine();
}
}
That's a very simple piece of code I'm writing right now. For some extremely odd reason, though, for the first player it gets into both if and else at once. It works fine except for player 1
. I've been reading my code over and over again for the past 30 minutes and it doesn't make ANY sense to me. So why is that happening and how can I fix it?
Aucun commentaire:
Enregistrer un commentaire