About 50 results
Open links in new tab
  1. java - What is the difference between iterator and iterable and how to ...

    On the flip side, Iterable is another interface, which, if implemented by a class forces the class to be Iterable and is a target for For-Each construct. It has only one method named iterator () which comes …

  2. java - What is the Iterable interface used for? - Stack Overflow

    Jun 29, 2009 · 0 The Iterable is defined as a generic type. Iterable , where T type parameter represents the type of elements returned by the iterator. An object that implements this interface allows it to be …

  3. How to use Iterator/Iterable in Java? - Stack Overflow

    Sep 23, 2014 · The Iterable interface is usually implemented by a collection of some sort. In your case, it is the Prison class, not the PrisonCell that could be declared to implement Iterable<PrisonCell>. * It …

  4. How can I implement the Iterable interface? - Stack Overflow

    Oct 29, 2015 · Iterable is a generic interface. A problem you might be having (you haven't actually said what problem you're having, if any) is that if you use a generic interface/class without specifying the …

  5. java - How can I make my class iterable so I can use foreach syntax ...

    Feb 2, 2014 · How can I make my class iterable so I can use foreach syntax? Asked 12 years ago Modified 4 years, 11 months ago Viewed 54k times

  6. java - Implementing the Iterable interface - Stack Overflow

    Dec 3, 2014 · How "old" is the exam paper where you read this ? I'm asking because it's very likely that it was written before Java 5 was released (therefore, before the word "iterable" meant the …

  7. java - Why is the iterator method present in both Iterable and ...

    Jul 8, 2018 · To make the existing java.util.Collection and all it's descendent interfaces and classes compatible with the enhanced for loop, they made java.util.Collection extend java.lang.Iterable. …

  8. java - Purpose of Iterable interface - Stack Overflow

    Similarly why cant any aggregation of objects just implement Iterator interface and imply that it is Iterable. class Employee{ Iterator getEmployeeIterator(){ return new EmployeeCollection(); } } class …

  9. Why is Java's Iterator not an Iterable? - Stack Overflow

    May 8, 2009 · Why does the Iterator interface not extend Iterable? The iterator() method could simply return this. Is it on purpose or just an oversight of Java's designers? It would be convenient to be able ...

  10. Can we write our own iterator in Java? - Stack Overflow

    May 1, 2011 · The best reusable option is to implement the interface Iterable and override the method iterator (). Here's an example of a an ArrayList like class implementing the interface, in which you …