I know I can use arrays, and lists, but what is it exactly that allows an object to be iterated over in a for-each loop? Does it need to be a Collection? Or an Iterable? Or an Iterator? My question is, what interface, or superclass does it need to implement/extend?
            Asked
            
        
        
            Active
            
        
            Viewed 37 times
        
    0
            
            
        - 
                    This might be helpful. Particularly the answer. http://stackoverflow.com/questions/20171235/java-lang-iterable-error-what-does-this-mean-and-how-do-i-fix-it?rq=1 – Lexi Jun 28 '16 at 17:42
- 
                    See also http://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work – Tunaki Jun 28 '16 at 17:42
- 
                    It needs to implement [Iterable](https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html) – Mr Bingley Jun 28 '16 at 17:43
- 
                    As @MrBingley already commented, it needs to implement Iterable. Additionally, for each loop is also supported for arrays. – OneMoreError Jun 28 '16 at 17:47
 
    