• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question about for loop...  RSS feed

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

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

Siva,

What happened when executed ? It happens to be infinite loop.
 
Anil Deshpande
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
 
Fred Hamilton
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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!