when I input any number into my scanner, it returns the else statement ALWAYS, and i'm stuck in an infinite loop. Can anyone help me out? I need to make the storyChoice variable String, and not Int because I plan on adding more else if statements that require the user input to be a string.
String storyChoice = keybd.next();
//This loop checks the scanner to see if the user has inputted an
//appropriate answer, as soon as the user inputs an appropriate answer
//The while loop terminates.
while(storyChoice != "1"|| storyChoice != "2" || storyChoice != "3")
{
if(storyChoice == "1")
{
Sword story = new Sword();
story.intro();
break;
}
else if (storyChoice == "2")
{
System.out.println("Not coded yet, so stay tuned!");
break;
}
else if(storyChoice == "3")
{
System.out.println("Not coded yet, so stay tuned!");
break;
}
else
{
System.out.println("Please choose an appropriate answer");
storyChoice = keybd.next();
}
}
Thank you.