public class RandomizedQueue<Item> implements Iterable<Item> {
private Item[] s;
private int N;
public Iterator<Item> iterator() {
return new RQIterator<Item>();
}
private class RQIterator<Item> implements Iterator<Item> {
private Item[] copy;
private int newItems;
public RQIterator() {
copy = (Item[]) new Object[N];
for (int i = 0, k = 0; i < s.length; i++) {
if (s[i] != null)
copy[k++] = s[i];
}
newItems = N;
}
//hasNext(), next(), remove() methods..
}
}
On the line copy[k++] = s[i]
, I am getting the Error: Type mismatch: cannot convert from Item to Item, but I can't figure out what's wrong. Can somebody tell? Thanks!