我有以下代码,稍后我将尝试使用用户在 if/else 语句中输入的输入:
String userGuess = JOptionPane.showInputDialog("The first card is "
+ firstCard + ". Will the next card be higher, lower or equal?");
如何在此代码所在的 if/else 语句之外使用他们输入的单词,即“更高”、“更低”或“相等”?我需要他们回答的代码是:
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++;
}
编辑:谢谢你的帮助,我想通了!