«« Next » « Previous
«« Next » « Previous

Link Details

DZone can't read your mind. Tell us what you like! Login and vote now.
Link 91692 thumbnail

By PeterStofferis
via ibm.com
Published: Jul 02 2008 / 02:02

Wildcards can be very confusing when it comes to generics in the Java™ language, and one of the most common mistakes is to fail to use one of the two forms of bounded wildcards ("? super T" and "? extends T") when needed. You've made this mistake? Don't feel bad, even the experts have, and this month Brian Goetz shows you how to avoid it.
  • 15
  • 1
  • 1210
  • 477

Comments

Add your comment
User 119725 avatar

Peter Stofferis replied ago:

0 votes Vote down Vote up Reply
User 281050 avatar

cbang replied ago:

0 votes Vote down Vote up Reply

Seems to me that much confusion could have been avoided if generics were covariant. What's the technical reason this is not the case in Java? Are we back to the erasure issue?

User 179375 avatar

Ricky Clarkson replied ago:

0 votes Vote down Vote up Reply

cbang: Covariance in generics is only appropriate for some types. E.g., allowing you to upcast a list of cats to be a list of animals, then add a dog to it would be wrong.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.