I'm making a java console program, I'm taking input from the user however I want the program to only succeed if the selection given (string) is valid to the choices purposed from the console.
printGameMenu();
do
{
userChoice = getInput("Please make a selection");
}
while("".equals(userChoice));
Since I had problems using the
!= operator not working when comparing a string (nightmare), for the moment of learning I'm using the equals method, my question is what is the alternative method to equals?
I need this while loop to continue iterating WHILE the input is not equal to "q" or "p"
q for quitting the program and p for playing the game.
I need the opposite method to equals.