wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Enhanced for loops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Enhanced for loops" Watch "Enhanced for loops" New topic
Author

Enhanced for loops

Faisal A Khan
Greenhorn

Joined: Jul 02, 2010
Posts: 11
In the K&B book, Enhanced for loops are said to be new to Java 6.

But this was introduced in Java 5 wasn't it? What was using in Java 5?

Can you please either correct me or explain?

Regards
Harshit Sethi
Ranch Hand

Joined: Jul 16, 2010
Posts: 75
enhanced for loop was introduced in java 6 to specifically iterate over arrays and collections .Before that and even in java 5.0 we used basic for loop .
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Faisal A Khan wrote:In the K&B book, Enhanced for loops are said to be new to Java 6.

But this was introduced in Java 5 wasn't it? What was using in Java 5?

Can you please either correct me or explain?

Regards


The foreach loop was introduced in java 5, as documented here -> http://download.oracle.com/docs/cd/E17476_01/javase/1.5.0/docs/guide/language/foreach.html


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Enhance for loop is introduced in java 5, check it here


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
mahesh shinde
Ranch Hand

Joined: Jul 24, 2009
Posts: 69

Its true Enhanced for loop is introduced in java1.5.
Harshit Sethi
Ranch Hand

Joined: Jul 16, 2010
Posts: 75
So this is an error in kathy sierra.Good work.
Faisal A Khan
Greenhorn

Joined: Jul 02, 2010
Posts: 11
Harshit Sethi wrote:enhanced for loop was introduced in java 6 to specifically iterate over arrays and collections .Before that and even in java 5.0 we used basic for loop .


I have used enhanced for loops in Java 5. Refer to http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#forloop

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enhanced for loops
 
Similar Threads
Enhanced for loop - new to Java 5 or Java 6?
scjp 1.5 exam suggestion
Book Differences
Discussing errata for K&B, SCJP 6
about Enhanced For loop