I made a small card based game in Netbeans. I went to build and test it in the console and it prints eveything twice before the user get to input there move. It does not do it in Netbeans. I am using scanner.netLine() to get my input from the console. Here is the code that causes the problem.
while(!turnFinished){
System.out.println(player);//Display the rack
System.out.println("Here is the discard pile card " + discard.peek());//Display the top card in the discard pile
System.out.println("If you want the discard pile card press y or press n to pick up a new card from the draw pile.";
String pickup = scanner.nextLine().trim().toLowerCase();
switch(pickup){
case "y","yes" -> {
player.drawCardFromDiscard(discard, player, drawPile);//If player decided to pick up from the discard pile
turnFinished = true;
}
case "n","no" -> {
player.drawCardFromDeck(drawPile, discard, player, false);//If player decided to pick up from the draw pile
turnFinished = true;
}
screenshot of netbeans Netbeans output and Windows cmd
I tried changing to scanner.next() instead of scanner.nextLine() but that didn't fix it either. I just want it to display the rack of cards once and wait for the users input like it does in Netbeans.

