• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

frustrated by this while loop

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
please just look at the while loop in this code, it is really frustrating for me, what is the problem?
thanks.


 
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

Firstly, which while loop? There are two in your code.

Secondly, tell us the details.

*Is it doing something you don't expect it to?

*Is it failing to do something you do expect it to do?

* Is it failing to compile (and if so show the compiler output).

* Is there an Exception (and if so show the full stacktrace).
 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
thank you.
i understood my problem
 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm glad you've solved your own problem. In the interest of sharing and making the most of this thread I invite you to run through what the problem was and how you solved it?
 
David Freed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you,
It was my stupid misunderstanding, I thought in every line of a while , the while checks for the condition, whereas it just checks the condition in the whle(condition) line, tha's it.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Freed wrote:It was my stupid misunderstanding, I thought in every line of a while , the while checks for the condition, whereas it just checks the condition in the whle(condition) line, tha's it.


Not stupid at all...If I said "keep repeating these steps while the light is green: turn around, jump, clap your hands, and sing a song", if you were in the middle of the song and the light turned purple, you'd probably stop singing right away. If you just finished turning and saw the purple light, you wouldn't jump or clap...You'd stop as soon as you noticed.

I can see why you'd think a program would work that way...but it doesn't. Look at it this way - now you know, and you'll never forget again.

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is more like a red light on the road. You keep going until you reach the red light; you do not stop 100 yards before it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic