About 16,000,000 results
Open links in new tab
  1. Java Iterator - W3Schools

    Java Iterator. An Iterator is an object that can be used to loop through collections, like ArrayList and HashSet. It is called an "iterator" because "iterating" is the technical term for looping. To use an Iterator, you must import it from the java.util package.

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

    Mar 5, 2014 · An iterator is just an implementation of the java.util.Iterator interface. If you're using an existing iterable object (say, a LinkedList ) from java.util , you'll need to either subclass it and override its iterator function so that you return your own, or provide a means of wrapping a standard iterator in your special Iterator instance (which ...

  3. Java | Implementing Iterator and Iterable Interface

    Jul 17, 2018 · Create an Iterator class which implements Iterator interface and corresponding methods. We can generalize the pseudo code as follows: class CustomDataStructure implements Iterable<> {

  4. Java Iterator - GeeksforGeeks

    Dec 20, 2024 · An Iterator in Java is an interface used to traverse elements in a Collection sequentially. It provides methods like hasNext(), next(), and remove() to loop through collections and perform manipulation. An Iterator is a part of the Java Collection Framework, and we can use it with collections like A

  5. Creating Custom Iterator in Java - Baeldung

    Mar 7, 2025 · An Iterator<E> is an interface in the Java Collections framework and provides methods that allow traversing through a collection. An Iterator instance can be obtained by calling the iterator() method on a Collection , such as a List , Set , and traversing elements individually.

  6. A Guide to Iterator in Java - Baeldung

    Jan 8, 2024 · In this tutorial, we’re going to review the simple Iterator interface to learn how we can use its different methods. We’ll also check the more robust ListIterator extension which adds some interesting functionality.

  7. How to use Iterator in Java? - GeeksforGeeks

    Jul 18, 2018 · An Iterator in Java is an interface used to traverse elements in a Collection sequentially. It provides methods like hasNext(), next(), and remove() to loop through collections and perform manipulation. An Iterator is a part of the Java Collection Framework, and we can use it with collections like A

  8. How to use Iterator in Java - Iterator Examples with List, Set, …

    Jul 18, 2024 · Java iterator interface explained. The complete guide to use iterator in Java with various code examples: iterate list, iterate set, iterate map, iterate queue, remove elements, etc.

  9. Iterator in Java with Example - Java Guides

    In this article, we will discuss how to use the Iterator interface in Java to iterate over collections such as ArrayList, LinkedList, and HashSet. We will cover the basics of using an Iterator, provide examples to demonstrate its usage, and show how to safely remove elements during iteration.

  10. How to create a custom Iterator in Java? - Stack Overflow

    Nov 2, 2017 · Given the iterable class Foo, which keeps always only one int value which is set on its constructor, make an iterator so it respects all of its restrictions which are: you can't change the int value after its initialization. You should include only the required exceptions to be thrown.

  11. Some results have been removed
Refresh