Forums Register Login

generics problem

+Pie Number of slices to send: Send
Hey guys
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
+Pie Number of slices to send: Send
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.


should fix the problem
+Pie Number of slices to send: Send
That's not the problem because I made silly mistake copying the code to the forum. I actually did write the throws clause in netbeans.
Sorry for that (updating my post now :p)
+Pie Number of slices to send: Send
Okay, then the problem is not in the code you are showing us. This compiles just fine in eclipse, IntelliJ, and on command line:

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Sometimes pc's can drive someone crazy

I solved the problem by first removing the @override. Then netbeans and the compiler just accepted.
After that I could just put the @override back with no problems :s

Thanks a lot for the help :p
+Pie Number of slices to send: Send
Convince yourself it's @Override, not @override.
+Pie Number of slices to send: Send
 

Kurro Zaki wrote: . . . updating my post now :p)

No, please don't update your post. It makes Steve Luke's response look like nonsense.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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)
+Pie Number of slices to send: Send
 

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.
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 984 times.
Similar Threads
Ho to not use casting on this generics?
How do you extend a generic abstract class
abstract method INFO Plz?
placing images in applets
Does an interface extend Object?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:46:46.