I create an abstract class with generic parameter T and an abstract method that return T.
The I extended the abstract class (like this: ImageLoader extends Retryable<Image>) and now logicall the method should return Image instead of T.
If i use implement abstract methods in netbeans the return type become Image (as expected) however netbeans, and the java compiler keep complaining
that the class doesn't implement all abstract methods :s
I don't think this is a generics problem. The problem is that the throws clause is part of the method signature. When you attempt to override the method you do not provide the throws clause, so the method doesn't have the same signature as the one you are trying to override - and therefore does not override it.
Also, you can drop any exception from the overridden method's throws list, and even specialize it (e.g. declare to throw FileNotFoundException where the overridden method throws the more general IOException).
I've tried your example, replacing the "a bit of code" with "Image image = null;", and it compiled successfully. Are you sure that Retryable doesn't have any other abstract methods? Also, Eclipse can give quick fixes, including implementing the missing methods. I'm sure Netbeans can do the same. That way you can see which methods you forgot to override.
Kurro Zaki wrote: . . . I solved the problem by first removing the @override. . . .
What override annotation? You didn't have one in the code you posted: please read this. I have come upon this thread late and can't understand it because of these changes. And SvH is right: it's @Override not @override.
Man I'm getting to used to netbeans doing stuff for me the I forgot that @Override is with a capital. It just a capital not some thing that's very wrong. Netbeans would have complained :p
Also I didn't include it because it's just a hint, it's not strictly necessary but in netbeans it had @Override and that shouldn't make a difference (at least I think so)
Kurro Zaki wrote: . . . It just a capital not some thing that's very wrong. . . .
You are using a case-sensitive language; that capital letter missed out is very wrong. You need to become obsessional about such things. You are giving me the impression that you are depending on NetBeans all the time, and that dependency is hindering your learning.
Also I didn't include it because it's just a hint, it's not strictly necessary . . .
But you mentioned it later, which made the discussion very confusing.
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop