我不确定为什么guess
与words[random][0]
相同,即使我输入了正确的答案。它会跳过if语句并转到else
。
do{
System.out.println("The scrambled word is: " + scramble[random]);
Scanner fooBar = new Scanner(System.in);
System.out.println("What is this word?: ");
guess = fooBar.next();
if(guess == words[random][0])
{
System.out.println("Congratulations, you have guessed correctly!");
done = true;
}
else
System.out.println("Sorry, that is not it.");
}while(done == false);