I'm figuring out something about the new Java for each loop. As I noted, this new construct allows you to use for to iterate over 1) arrays, and 2) anything that implements the Iterable interface.
Where the confusion here sets in for me is that #2 is not "allows you to use for to iterate over an Iterator." There's quite a distinction there.
So I'm dealing with an API that gives me three methods that return Enumerations full of interesting stuff and one method that returns an Iterator full of interesting stuff. (Silly design; they should all be one or the other, and my understanding is the modern way to do this is with Iterators.) And I'd like to plug them all into a nice method with a for each loop to do something with them, but I can't since I can't use the for each loop on either Enumerations or Iterators, directly. And I'd still like to write one routine to deal with all of these, but the methods to call to traverse Enumerations are not the same as the ones for Iterators.
If I could find a nice way to create a Collection of any type directly from Enumerations and Iterators, without having to code it myself, that would make this much cleaner. All Collections apparently implement the Iterable interface. But this is really getting silly; the whole point of having an Iterator is you've already pulled it out of the relevant Collection and shouldn't have to deal with it again. How much would it take for Java's for loop to just support Enumerations and Iterators?