I have the following piece of code, and I'm trying to use the input entered by the user in if/else statements later on:
String userGuess = JOptionPane.showInputDialog("The first card is "
+ firstCard + ". Will the next card be higher, lower or equal?");
How can I use the word they input, i.e. "higher", "lower" or "equal" outside of the if/else statement that this code is in? The code I need their answer for is:
if (userGuess == "higher" && nextCard > firstCard)
{
String userGuess = JOptionPane.showInputDialog(null, "Correct! The current card is a "
+ nextCard + ". Will the next card be higher, lower or equal?");
correctGuesses++;
}
EDIT: Thank you for your help, I figured it out!