• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loops  RSS feed

 
Ci Mc
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm currently using the book - How to program using Java. I'm having trouble understanding how this loop is broken, I can't understand how the boolean finished is set to false and breaks the While loop.
If somebody could explain it to me I'd be very grateful.

 
Ninad Kulkarni
Ranch Hand
Posts: 802
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code formatted
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ci Mc wrote:I can't understand how the boolean finished is set to false and breaks the While loop.

your while loop has a not operator. So if finsished is false, the loop executes. It is when finsihesd is set to true that the loop exits.
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I added code tags to your post, too. Doesn't it look better Unfortunately some of the lines are too long.
Which book was it and which page? Was it a Deitel book? That doesn't look like Deitel code.

That code seems designed to confuse, because you have two loops, one a while and the other a do loop. You can read about those loops in the Java Tutorials. We don't simply give out explanations. We like to see what you have done. Please explain where you think the two loops are, and what they do. Start with the inner loop. Go through that and explain how you think that works. Then (maybe later) do the same for the outer loop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!