Ask Question
27 April, 02:02

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.

+3
Answers (1)
  1. 27 April, 02:09
    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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers