public class RandomizedQueue- implements Iterable
- {
private Item[] s;
private int N;
public Iterator
- iterator() {
Your inner class RQIterator
is declaring a new type parameter Item
that is distinct from the type parameter Item
that its enclosing class RandomizedQueue
is declaring.
However, the Item
type parameter from RandomizedQueue
is still in scope, because RQIterator
, as a nested class, isn't a static
nested class. Just use Item
from RandomizedQueue
.
private class RQIterator implements Iterator- {
Also the creation of the iterator in iterator()
won't need the type parameter either.
public Iterator- iterator() {
return new RQIterator();
}