Why can't i break out of this while loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why can't i break out of this while loop?

I have been playing around with Java and I can't seem to break out of the while loop. I have tried using while and do-while loop, both with and without if statements and I keep getting the same issue. the code runs without any error. any help? https://code.sololearn.com/caf4mpt1aKio

5th Oct 2019, 3:16 PM
Daniel Norfolk
Daniel Norfolk - avatar
3 Answers
+ 2
For Strings use the equals method: choice.equals("stop") returns true if you enter stop.
6th Oct 2019, 5:31 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
There is no direct String comparison in Java. For that you should always use equals() method.
6th Oct 2019, 5:50 PM
A͢J
A͢J - avatar
+ 2
Please write your code in Sololearn Playground and share that link here so we can check that.
5th Oct 2019, 3:28 PM
A͢J
A͢J - avatar