Ask Question
28 August, 13:41

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.

+2
Answers (1)
  1. 28 August, 14:10
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers