public class abc<X extends Z> implements Iterable<X>
{
protected ArrayList<X> list;
public Iterator<X> iterator()
{
return list.iterator();
}
}
I get a ‘cannot find symbol’ error for the iterator method. I have honestly no clue why.
You should give the exact error message, but my guess is that you need to import the
Iteratorclass (java.util.Iterator).Also the way you have declared
Xrequires that you have some other class namedZ(Xis restricted toZor subclasses ofZ). Is this true? If it is, you should rename it as only type parameters should have single-character names. If it’s not true, and you are consideringZanother type parameter, you would need to declareZas a type parameter somewhere.