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.
Comments
Peter Stofferis replied ago:
Part 1 see:
http://www.dzone.com/links/java_theory_and_practice_going_wild_with_generics.html
cbang replied ago:
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?
Ricky Clarkson replied ago:
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.
Voters For This Link (15)
Voters Against This Link (1)