wood burning stoves 2.0*
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

Nazma Panjwani
Greenhorn

Joined: Jan 17, 2010
Posts: 16
Hi,

What does this statement mean....In Java, a while loop cannot have an empty condition but a for loop can. Can you give examples please???


Thanks
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
Example of a for loop with empty condition:



That for loop is perfectly acceptable, although it is an infinite loop. However, the following while loop is not valid:



This will not work. You have to have some sort of boolean, or expression that results in a boolean, in the while condition.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13868
    
  10

W. Joe Smith wrote:Example of a for loop with empty condition:


This will not work, because there is one ; too many.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: for loop
 
Similar Threads
java.sql.SQLException: Missing IN or OUT parameter at index::
WA #2 ..... word association
for loop within a while?
Dynamic link in JSP
Batch Update question