File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Ending a loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

Ending a loop

Joey McGee

Joined: Nov 22, 2012
Posts: 27
Below is the code where I've created a loop and am trying to code it to end if the user types in no... If anyone could help me with this it would be greatly appreciated.
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 187
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

break statement would do the job, of course in your case combined with proper check for user input.

The quieter you are, the more you are able to hear.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
If you are going to have that do‑while loop, you are far better writing it like thisYou will have to check whether answer is still in scope if it is declared inside the loop.
I agree. Here's the link:
subject: Ending a loop
It's not a secret anymore!