Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

for(;;) loop

 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of for loops is this one?

for(;
{
//some logic here
}

what is the significance of it?...what does it do?...how much it differs form the regular for loop?

Thanks in addvance
 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i mean this for(; loop i don't know where that smily face came from ranchers
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ammar,

for(;;) will result in an infinite loop since there is no condition to stop the loop.

Jeff
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ammar Salem:
i mean this for(; loop i don't know where that smily face came from ranchers

When posting code, be sure to click the 'disable smilies' check box.
 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeff.....
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ammar Salem/omar salem, are you posting from two different accounts?
 
omar salem
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are two different people...but brothers
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the loop can be prevented from becoming an infinite loop, if you break or return from within it,



aside: the same as


and while I would suggest not using either,
i find the second preferable for readability reasons,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic