Why is there a method iterator() on java.util.Collection
问题 Why is there the method iterator() defined on the interface java.util.Collection when it already extends java.util.Iterable which has this very method defined. I'm thinking some sort of backward compatability or an opportunity to write some JavaDoc on the method at the collection level. Any other ideas? 回答1: Backwards compatibility. Iterable was not introducted until 1.5 with the for(Object o : iterable) construct. Previously, all collections had to provide a means to iterate them. 回答2: I