title: Java: Trying to take keyboard input and evaluate it in an if/else condition to set a boolean value to true or false
body: <p>I'm working on building out a sample dice rolling game that rolls the dice 10 times unless interrupted by user input.</p>
  
  <p>I have a while statement that runs based on the state of two boolean values, one of which is set based on the user input.</p>
  
  <p>My current progress is below. Any suggestions would be a huge help!</p>
  
  <pre><code>import java.util.Scanner;
  import java.swing.JOptionPane;
  import java.util.Random;
  
  
  public class DiceGame
  {
     public static void main(String[] args)
     {
  
  
       Random rand = new Random();
  
  
        int player1Wins = 0;
        int player2Wins = 0;
        int ties = 0;
        int rollCount = 0;
        boolean rollAgain = true;
  
        while (rollCount &lt; 10 &amp;&amp; rollAgain)
        {
           int player1Dice = rand.nextInt(6) + 1;
           int player2Dice = rand.nextInt(6) + 1;
  
           if (player1Dice &gt; player2Dice)
           {
              player1Wins++;
              System.out.println("Player 1 wins!!");
           } 
  
           else if (player2Dice &gt; player1Dice)
           {
              player2Wins++;
              System.out.println("Player 2 wins!!");
           }
  
           else 
           {
              ties++;
              System.out.println("It's a tie...");
           }
  
           rollCount++;
           String answer;
           Scanner keyboard = new Scanner(System.in);
           System.out.println("Would you like to roll again? Press y for yes");
           answer = keyboard.nextLine();
  
           if (answer == "y") 
           {
              rollAgain = true;
           }
  
           else
           {
              rollAgain = false;
           }
  
        }
        System.out.println();
        System.out.println("Player 1 Total wins: " + player1Wins);
        System.out.println("Player 2 Total wins: " + player2Wins);
        System.out.println("Total Ties: " + ties);
        System.out.close();
     }
  }
  </code></pre>