• Post Reply Bookmark Topic Watch Topic
  • New Topic

using do while?  RSS feed

 
Aida Khalidah
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to use do while?
 
John Joe
Ranch Hand
Posts: 443
3
Android Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may refer to this

https://www.tutorialspoint.com/java/java_do_while_loop.htm
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and welcome to the Ranch
What do you want a do loop for? Remember it always runs once whether it needs to or not. Maybe if you are reading from a file, you always want it to run:-If no error occurs, you will set needsReading to false and the loop will run once. If an error occurs, needsReading will remain true and you can then take the opportunity to try again. Maybe you can correct the file name or something like that and the loop will try to read again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!