As you know, the java.util package includes a standard Iterator<E> interface which has two abstract methods: boolean hasNext() and E next(), as well as two default methods: void remove() and void forEachRemaining(Consumer<? super E> action). Your task is to create an iterator implementing the Iterator<E> interface for the HyperList class. You must implement both abstract methods and override the void remove() method so that it will remove the element returned by the next() method.
Your implementation must comply with the following contract:
hasNext()must return true only if there are more elements to iterate.next()must throwNoSuchElementExceptionif the iteration has no more elements.remove()must throwIllegalStateExceptionif the next method has not been called yet.