Ask Question
11 January, 12:53

eate a class which is an iterator for the LinkedCollection. This class must implement the Iterator interface. You must think about what field (s) you need to keep track of the current element in the iteration, how to initialize the field (s), how to move to the next element, and how to know when all elements have been returned.

+5
Answers (1)
  1. 11 January, 14:29
    0
    class CustomDataStructure implements Iterable {

    / / code for data structure

    public Iterator iterator () {

    return new CustomIterator (this);

    }

    }

    class CustomIterator implements Iterator {

    / / constructor

    CustomIterator (CustomDataStructure obj) {

    / / initialize cursor

    }

    / / Checks if the next element exists

    public boolean has Next () {

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “eate a class which is an iterator for the LinkedCollection. This class must implement the Iterator interface. You must think about what ...” in 📘 English if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers