This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

Ending a loop

 
Joey McGee
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
  • Report post to moderator
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
break statement would do the job, of course in your case combined with proper check for user input.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49751
69
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic