• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Question about for loop...

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happend when for(; ;) executing...

for(; ;){
......
.........
}
Thanks Sir in advance.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Siva,

What happened when executed ? It happens to be infinite loop.
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works like a infinite loop. Any for loop contains three consctucts. Initialization, expression evaluation (always to boolean) and finally third part Increment or decrement part.

Since youe for loop doesn't have any of these i will go into infinite loop

Hope this Helps
 
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use this infinte loop code in the run() method of an animation thread, or any kind of continuously running thread for that matter. From within the loop you can monitor a variable that tells you when to stop executing the loop.
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd still use "while (true)" any day of the week.
 
Fred Hamilton
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Prime wrote:I'd still use "while (true)" any day of the week.



heh heh you know what? I like your method better. I'm gonna switch.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!