If I tell you that a for-each loop over a java.lang.Iterable (because that's what's being used in the for-each loop, not java.util.Collection, java.util.List or java.util.Set; those all extend java.lang.Iterable) uses the java.util.Iterator returned by the iterator() method, can you perhaps find the answer yourself?
I think Chitta wants a for-loop like those of Java 1.4 and before. Having to migrate existing code from Java 5.0/6 to Java 1.4 (for whatever reason) is the only reason I can think of for wanting to convert this loop.
Rob Spoor wrote:I think Chitta wants a for-loop like those of Java 1.4 and before. Having to migrate existing code from Java 5.0/6 to Java 1.4 (for whatever reason) is the only reason I can think of for wanting to convert this loop.
or it's a simple homework problem
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor wrote:I think Chitta wants a for-loop like those of Java 1.4 and before. Having to migrate existing code from Java 5.0/6 to Java 1.4 (for whatever reason) is the only reason I can think of for wanting to convert this loop.
or it's a simple homework problem
I don't know, it doesn't look like homework to me. But on the other hand I would hate for that code to be real-life production code too.
Rob Spoor wrote:I think Chitta wants a for-loop like those of Java 1.4 and before. Having to migrate existing code from Java 5.0/6 to Java 1.4 (for whatever reason) is the only reason I can think of for wanting to convert this loop.
or it's a simple homework problem
Well, that's part of the reason why I only posted a hint and didn't type out the complete solution.