title: User input to repeat program in Java
body: <p>I am writing a simple guessing game program where the user will input a number to try and guess a randomly generated number. </p>
  
  <p>If they get the number right I want to give them the option to play again.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>public class GuessingGame {
      private Random num = new Random();       
      private int answer = num.nextInt(10);   
      private int guess;  
      private String playAgain;  
  
      public void inputGuess(){
          System.out.println("Enter a number between 1 and 10 as your first guess: ");
          Scanner input = new Scanner(System.in);
          guess = input.nextInt(); 
          do{
          if (guess &lt; 1 || guess &gt; 10){
              System.out.println("That is not a valid entry. Please try again: ");
              guess = input.nextInt();
          }else if (guess &gt; answer){
              System.out.println("Too high, Try Again: ");
              guess = input.nextInt();
          }else if (guess &lt; answer){
              System.out.println("Too low, Try Again: ");
              guess = input.nextInt();
          }
  
          }while (guess != answer);
  
          System.out.println("Congratulations, You guessed the number!");
          System.out.println("Would you like to play again? Enter Y to play or any other key to quit: ");
          playAgain = input.nextLine();
          if(playAgain == "Y" || playAgain == "y"){
              System.out.println("Enter a number between 1 and 10 as your first guess: ");
              guess = input.nextInt(); 
          }
  
      }
  }
  </code></pre>
  
  <p>The game plays through but when the user is prompted to play again nothing happens?</p>
  
  <p>Any suggestions?</p>