title: When I run my Java program which has a Scanner object, the Windows Wait Cursor is always there. How can I change this?
body: <p>I have a Java game in which you play Blackjack, and I use a Scanner to take input for things like "hit" and "stay." When I run it, the <a href="https://en.wikipedia.org/wiki/Windows_wait_cursor" rel="nofollow noreferrer">Windows wait cursor</a> shows up and doesn't go away until I close the program. I tried to use Scanner's close() method, but that throws an exception.</p>
  
  <p>here's the code:</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.ArrayList;
  
  public  class CardGame {
  
      public static ArrayList&lt;Card&gt; dealIn(ArrayList&lt;Card&gt; hand) {
  
          Card a = new Card();
          Card b = new Card();
  
          hand.add(a);
  
          while (hand.size() &lt; 2) {
              if (!b.equals(a)) {
                  hand.add(b);
              } else
                  dealIn(hand);
          }
          return hand;
      }
  
      public static int calcScore(ArrayList&lt;Card&gt; hand) {
  
          int sum = 0;
          int aces = 0;
  
          for (Card c : hand) {
              if (c.getCardValue().getFace().equals("A")) {
                  aces++;
              } else {
                  sum += c.getCardValue().getNumeric();
              }
          }
          while (aces &gt; 0) {
              aces--;
              if (sum &lt;= 10) {
                  sum += 11;
              } else {
                  sum += 1;
              }
          }
          return sum;
      }
  
      public static void main(String[] args) {
          Scanner in = new Scanner(System.in);
          System.out.println("Welcome to Blackjack!\n");
          ArrayList&lt;Card&gt; playerhand = new ArrayList&lt;Card&gt;();
          ArrayList&lt;Card&gt; dealerhand = new ArrayList&lt;Card&gt;();
          dealIn(playerhand);
  
          for (int i = 0; i &lt; 2; i++) {
              Card a = new Card();
              if ((!playerhand.contains(a)) &amp;&amp; (!dealerhand.contains(a))) {
                  dealerhand.add(a);
              }
          }
  
          // System.out.println("DEALER HAND: [hidden]" + " and " +
          // dealerhand.get(1));
          System.out.println("TEST DEALER HAND: " + dealerhand);
          System.out.println("Your hand: " + playerhand);
  
          while (!isBusted(playerhand)) {
              System.out.println("Your score is " + calcScore(playerhand) + ". Hit or stay?");
              String hOrS = in.nextLine();
  
              if (hOrS.equalsIgnoreCase("hit")) {
  
                  hit(playerhand);
                  System.out.println(playerhand);
  
                  if (isBusted(playerhand)) {
                      System.out.println("Your score is " + calcScore(playerhand) + "! YOU LOSE");
                      break;
                  }
                  // System.out.println(playerhand);
  
              }
              if (hOrS.equalsIgnoreCase("stay")) {
  
                  while (calcScore(dealerhand) &lt;= 17) {
                      Card n = new Card();
                      if (!dealerhand.contains(n)) {
                          dealerhand.add(n);
                          // System.out.println(dealerhand);
                      }
                  }
  
              }
  
              if (isBusted(dealerhand) || (!isBusted(playerhand) &amp;&amp; (calcScore(playerhand) &gt; calcScore(dealerhand)))) {
                  System.out.println("DEALER HAND: " + dealerhand);
                  System.out.println("YOUR HAND: " + playerhand);
                  System.out.println("YOU WIN");
                  // break;
              } else {
                  System.out.println(dealerhand);
                  System.out.println("YOU LOSE");
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>Is it possible to fix this?</p>