title: exit or continue the game in java
body: <p>afer program outputs a winner, i ask if user wants to play again or exit but for some reason scanner doesn't read this input(continue or not). I even put prompt for continuation outside the while loop but still no luck:
  "|XXX|
   | O |
   |  O|</p>
  
  <p>Player X is a winner!
  Do you want to play again? Enter Y for yes or N for no!
  BUILD SUCCESSFUL (total time: 26 seconds)
  "</p>
  
  <p>This is code:</p>
  
  <pre><code>public class TicTacToeRunner
  {
     public static void main(String[] args)
     {
        int row;
        int column;
        Scanner in = new Scanner(System.in);
        TicTacToe game = new TicTacToe();
        String player = "X";
        boolean done = false; 
        int moveCounter = 0;
        String answer;
  
  
         int noMovement = -2;
         int toQuit = -1;
         int movesToCheckWins = 5;
         int movesToCheckTies = 7;
  
  
  
        while (!done) 
        {
  
           do
           {
              row = column = noMovement;
  
              System.out.print("\n" + game);
              System.out.print("Please make a move " + (moveCounter + 1) + "(" + player + ")\nRow for " + player.toUpperCase() + " (or -1 to exit): ");
  
              if (in.hasNextInt()) //check if input is an integer
               {
                 row = in.nextInt();
               }
  
               if (row == toQuit) //if entered -1 quit the game
               {
                   done = true;
                   System.out.println("Player " +player.toUpperCase() + " ended the game !");
                   System.exit(0); //game termination
               }
               else
               {
                  System.out.print("Column for " + player.toUpperCase() + ": ");
                  if(in.hasNextInt()) //check if input is an integer
                   {
                    column = in.nextInt();
                   }
               }
           }while(!game.checkForValidMove(row, column)); //end of do-while loop if checkForValidMove is false
  
          moveCounter++;
          game.set(row, column, player);
  
          if (moveCounter &gt;= movesToCheckWins) //check wins after 5 moves
          {
              if (game.checkForWin(row, column, player)) //if a winner
              {
                  done = true;
                  System.out.println("\n" + game);
                  System.out.println("Player " + player.toUpperCase() + " is a winner!");
  
              }
          }
  
          if (moveCounter &gt;= movesToCheckTies) //Check for ties after 7 moves
          {
              if (game.checkForEarlyTie()) //check for early tie
              {
                  done = true;
                  System.out.println("\n" + game);
                  System.out.println("Tie Game after " + moveCounter + " moves!");
  
              }
          }
  
  
       // Switching players 
  
       if (player.equals("X"))
       {
             player = "O";
       }
          else
       {
             player = "X";
       }
  
  
        }
  
  
                  System.out.println("Do you want to play again? Enter Y for yes or N for no!");
  
                  answer = in.nextLine();
                  answer = answer.toLowerCase(); //change input to lowercase for bullet proofing
                  if(answer.equals("y"))
                  {
                  done = false;
                  player = "X";
                  moveCounter = 0;
                  game.resetTheGame();
  
                  }
  
                else
                   {
                   System.exit(0); //program termination
                 }
  
  
    }
  
  }
  </code></pre>