View RSS Feed

Recent Blogs Posts

  1. Supertype Wildcards with Generics

    by , 11-30-2011 at 12:12 AM
    In my last tip, I showed how you can use a wildcard with generics. It is also possible to use a supertype wildcards. In this case the wildcard is bounded by any base class of a particular class, by specifying <? super MyClass> or even using a type parameter: <? super T> (although you cannot give a generic parameter a supertype bound; that is, you cannot say <T super MyClass>). This allows you to safely pass a typed object into a generic type. Thus, with supertype wildcards you ...