problem with while statement :(

i am having a problem with my while statement, can anyone help me to get it working :(

i am trying to get the while statement to only run when the input hasnt been a yes or a no, can someone please help me.

System.out.print("Are you a Resident? (yes/no): ");

Resident = console.next();//Requests resident status from user and puts in in Resident

while ((Resident !="yes") && (Resident !="no"))

{

System.out.print("error - You didnt type yes or no. Try again: ");

Resident = console.next();

}

[773 byte] By [balistica] at [2007-11-27 0:17:55]
# 1

while ((Resident != "yes") && (Resident != "no"))

Don't compare Strings with ==, use the equals() method instead.

while(!("yes".equals(Resident) && "no".equals(Resident)))

CaptainMorgan08a at 2007-7-11 22:07:23 > top of Java-index,Java Essentials,New To Java...
# 2

I think the Captain meanswhile(!("yes".equals(Resident) || "no".equals(Resident)))

// or

while(!"yes".equals(Resident) && !"no".equals(Resident))

pbrockway2a at 2007-7-11 22:07:23 > top of Java-index,Java Essentials,New To Java...
# 3
> I think the CaptainYup, thanks for that.
CaptainMorgan08a at 2007-7-11 22:07:23 > top of Java-index,Java Essentials,New To Java...
# 4
thanks guys ^_^ you rock
balistica at 2007-7-11 22:07:23 > top of Java-index,Java Essentials,New To Java...