How do I solve this error? I tried just this, and (Article) this, and super.iterable(), but nothing seems to work. Only types of Article will ever be added to this queue. Java 1.7.0_03.
[javac] C:\cygwin\home\Chloe\Queue.java:26: error: incompatible types
[javac] for (Article a: (Iterable) this) {
[javac] ^
[javac] required: Article
[javac] found: Object
Here is the source code.
public class Queue<T> extends ArrayDeque {
public int words() {
int words;
for (Article a: (Iterable) this) {
}
}
}
The iterator of your queue will return
TObjectinstances, notArticle. Your loop should go like this:Or, if you need an article queue, declare the class this way: