重複の可能性:
Java で文字列を比較するにはどうすればよいですか?
以下のコードに問題があります。No try again
問題は、最初にマップを言わなかった後、「マップ」と入力するかどうかに関係なく、入力ボックスで 繰り返されることです。
System.out.println("My cousin Diego is in trouble in the Majestic palace. But how do we get there?");
System.out.println("Who do we call when we don't know where to go? Huh? I didn't get that...");
imTheMap=robotMagic.next();
if (imTheMap.equals("map"))
{
System.out.println("That's right!"); //the issue is here
}
else
{
while(imTheMap!=("map"))
{
System.out.println("No! try again");
imTheMap=robotMagic.next();
}
}