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

    Jul 28, 2011 · Iterator is class that manages iteration over an Iterable. It maintains a state of where we are in the current iteration, and knows what the next element is and how to get it.

  2. loops - Ways to iterate over a list in Java - Stack Overflow

    Essentially, there are only two ways to iterate over a list: by using an index or by using an iterator. The enhanced for loop is just a syntactic shortcut introduced in Java 5 to avoid the tedium of explicitly …

  3. How do I efficiently iterate over each entry in a Java Map?

    If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map? Will the ordering of

  4. java - What is the best way to get the count/length/size of an iterator ...

    Iterators are what they are; to iterate to the next object of a collection (it can be anything like set, array, etc.) Why do they need to tell the size when they don't care what they are trying to iterate for? to …

  5. java - Which is more efficient, a for-each loop, or an iterator ...

    Iterator is an interface in the Java Collections framework that provides methods to traverse or iterate over a collection. Both iterator and for loop acts similar when your motive is to just traverse over a …

  6. What are the benefits of using an iterator in Java

    I'm wondering what are the benefits of using an implementation of the Iterator interface instead of using a plain-old for-each loop?

  7. java - How does next () method on iterators work? - Stack Overflow

    Dec 6, 2017 · At the very first iteration, the iterator starts pointing to element with index 0? or like the "index -1" ? I ask because as far as I know the next() method returns the next element in the collection.

  8. What does it mean to return an iterator? Java - Stack Overflow

    Oct 25, 2014 · 2 Returing an iterator means returning an instance of a class that implements the Iterator interface. This class has to implement hasNext(), next() and remove(). The constructor of the class …

  9. java - How Iterator's remove method actually remove an object - Stack ...

    We all know that the safest "and probably only safe" way of removing an object from a collection while iterating it, is by first retrieving the Iterator, perform a loop and remove when needed; Ite...

  10. what is the c# equivalent of Iterator in Java - Stack Overflow

    Apr 5, 2014 · 19 I am manually converting Java to C# and have the following code: ... Is there an equivalent of Iterator<T> in C# or is there a better C# idiom?