We help IT Professionals succeed at work.

checking strings in a while statement

sjsharp80
sjsharp80 asked
on
Hi,

I have a simple while loop
while ((rolled != go)  || ( chances < 6))

I know this doesn't work as I'm comparing 2 strings that refer to different objects, how can I convert the comparison rolled != go so it does work (not equal to).

thanks
Comment
Watch Question

try this
 
while(!rolled.equals(go) || changes<6) {
}
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
while(!rolled.equals(go) && chances<6) {

Explore More ContentExplore courses, solutions, and other research materials related to this topic.