File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes for(;;) loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "for(;;) loop" Watch "for(;;) loop" New topic
Author

for(;;) loop

Ammar Salem
Ranch Hand

Joined: Dec 29, 2007
Posts: 60
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


****************************<br />For Some Dreams.....<br />One Lifetime Is Not Enough.<br />****************************
Ammar Salem
Ranch Hand

Joined: Dec 29, 2007
Posts: 60
i mean this for(; loop i don't know where that smily face came from ranchers
Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230
Ammar,

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

Jeff


Jeff Storey
Software Developer
[url]http://jeffastorey.blogspot.com[/url]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
omar salem
Ranch Hand

Joined: Aug 22, 2006
Posts: 34
Thanks Jeff.....


Have a sip of Java !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Ammar Salem/omar salem, are you posting from two different accounts?
omar salem
Ranch Hand

Joined: Aug 22, 2006
Posts: 34
We are two different people...but brothers
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
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,


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
 
subject: for(;;) loop
 
Similar Threads
Array list > for loop or iterator
java.io.IOException:Too many files open
read text file
Confusing Output
Program to Access an Array Using a Command-Line Argument