Enhanced for-loop does not accept Iterator
问题 Excuse me if this has been asked before. My search did not bring up any other similar question. This is something that surprised me in Java. Apparently, the enhanced for-loop only accepts an array or an instance of java.lang.Iterable . It does not accept a java.util.Iterator as a valid obj reference to iterate over. For example, Eclipse shows an error message for the following code. It says: " Can only iterate over an array or an instance of java.lang.Iterable " Set<String> mySet = new