Mark Moge wrote:Can you explain me why the first method is ok and the second one gives a compile error?
yes, Java does not support return-type-based method overloading. Java methods only differ by arguments, not by return type. So, to the compiler the useMe() method and the useMe() method are exactly the same.
That is why the compiler says: useMe() is already defined in A
I have checked again and I can compile it too but my IDE (netbeans) gives me warnings which look like a compile error.
Anyway I dont understand why one method is ok and second one isn't. And if sth is super of K (A<? super K>) then it doesn't have to extends Number (like in a class declaration).
A.java:5: error: type argument ? extends K#1 is not within bounds of type-variab
abstract <K> A<? extends K> useMe();
where K#1,K#2 are type-variables:
K#1 extends Object declared in method <K#1>useMe()
K#2 extends Number declared in class A