View Single Post
  #1 (permalink)  
Old 02-10-2008, 07:13 PM
Cero.Uno Cero.Uno is offline
Member
 
Join Date: Feb 2008
Posts: 2
Cero.Uno is on a distinguished road
Comparison of Strings
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.

Code:
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.

Last edited by Cero.Uno : 02-10-2008 at 07:17 PM.
Reply With Quote
Sponsored Links