File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Enhanced for loop in Java5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enhanced for loop in Java5" Watch "Enhanced for loop in Java5" New topic

Enhanced for loop in Java5

niranjan karkera

Joined: Feb 06, 2008
Posts: 1
for(int e: a[])
//print the value of e

is there any approach to get the index value of array
(eg: in the earlier version of for loop we could retrieve the index i value)
Sheikh Sadiruddin

Joined: Aug 10, 2007
Posts: 21

SCJP 6 (80%) || SCWCD 5 (92%)
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
If you need the index, just use the old for loop.
I agree. Here's the link:
subject: Enhanced for loop in Java5
It's not a secret anymore!