• Post Reply Bookmark Topic Watch Topic
  • New Topic

warning for not overriding methods  RSS feed

 
Abigail Decan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

my compiler is telling me that the getList... method is not being overridden.
but when I change the JList<String> to JList and Object to String in the parameters, i get a warning from the compiler that it's an "unchecked call".
what am i supposed to do?
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I look at the API documentation for the ListCellRenderer interface, it says that the signature of that method is



Now, in your case your value for the type parameter E is String. So your declared signature for the method isn't quite right. You tried to change the right thing, but you didn't change it correctly. Look again at the method signature from the documentation to see what you're missing.
 
Abigail Decan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.
I looked at the API's example code, and it had JList<?>.
i put <? extends String> and it compiled.

i didn't know you could put ? there.
can you tell me what ? exactly is.
the documentation doesn't really explain.
 
Paul Clapham
Sheriff
Posts: 22844
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I'm not going to tell you because Oracle has written a tutorial about Generics which is far superior to whatever lame explanation I might attempt. The tutorial is here: http://docs.oracle.com/javase/tutorial/java/generics/ and the part you're asking about is in the pages named "Bounded Type Parameters" and "Wildcards".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!