attempting to use incompatible return type

Hi.

Why the following code gives me

GenericReturn.java:15: test.B1.InnerB is not abstract and does not override abstract method f1() in test.A1.InnterA

class InnerB extends A1<?>.InnterA {

^

GenericReturn.java:18: f1() in test.B1.InnerB cannot override f1() in test.A1.InnterA; attempting to use incompatible return type

found:java.util.Collection<? extends test.A1<capture of ?>.InnterA>

required:java.util.Collection<? extends test.A1<capture of ?>.InnterA>

public Collection<? extends A1<?>.InnterA> f1() {

^

GenericReturn.java:17: method does not override a method from its superclass

@Override

class A1<Textends A1>{

abstractclass InnterA{

publicabstract Collection<?extends InnterA> f1();

}

}

class B1extends A1<B1>{

class InnerBextends A1<?>.InnterA{

@Override

public Collection<?extends A1<?>.InnterA> f1(){

returnnull;

}

}

}

Thanx.

[1859 byte] By [jnbua] at [2007-10-2 5:43:37]
# 1

Try This

class A1<T extends A1> {

abstract class InnterA {

public abstract Collection<? extends InnterA> f1();

}

}

class B1 extends A1<B1> {

class InnerB extends A1<B1>.InnterA {

@Override

public Collection<? extends A1<B1>.InnterA> f1() {

return null;

}

}

}

It may not be exctly what you wnated it to be. I think it does not allow you to access A1<?> from a specific implementer of A1, B1 extends A1<B1>, has specified its references to A1 from <?> to <B1>

haroonzca at 2007-7-16 1:53:42 > top of Java-index,Core,Core APIs...