I am implementing an interface I on a class A. Class A implements I.
I have an Iterator T that is supposed to return an object which implements I everytime I call next.
My iterator goes as follows (of course omitting other stuff):
public class T<I> implements Iterator<I> {
@Override
public I next() {
return new A();
}
}
However, I get this error: Required I, found A (for the return new A() line)....
I don't know what is happening. Can someone help me?
AtoIfor this code to work.return new (I)A();AimplementsI. Please show the code.