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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Enhanced for loop in Java5" Watch "Enhanced for loop in Java5" New topic
Author

Enhanced for loop in Java5

niranjan karkera
Greenhorn

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
Greenhorn

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Enhanced for loop in Java5
 
Similar Threads
How to get multiple values using System.getProperty
How do you add objects to arrays?
Linked List - inserting value to correct position
append objects to array
Problem with Array.