So here’s what I have:
- 1 interface called Set
- 1 abstract class which implements set
- 2 classes which extend the abstract class, called
ArraySetandListSet
So in Set, I state Iterator <String> iterator(); and then in my 2 nonabstract classes, I have nested classes which are called ArrayIterator and ListIterator, which implement the iterator’s functionality. But the compiler complains that ArraySet and ListSet must
implement Set.iterator(). How do I make it so that the compiler recognizes that ArrayIterator and ListIterator are the implementations of Set.iterator()?
So it looks like
interface Set extends Iterable< String > {
...
Iterator< String > iterator(); }
class ArraySet extends AbstractClass {
...
class ArrayIterator implements Iterator< String > { ... }
...
}
You need to implement
Set.iterator()in your non-abstract classesArraySetandListSet, ie:In
ArraySet:In
ListSet:Also, I assume that both
ArrayIteratorandListIteratorimplementsIterator