Java (1.6) generics wildcard

Viewed 291

Consider flowing situation:

    class A {

    }

    class B extends A {

    }


    List <? extends A> x = new ArrayList<A>();
    List <? extends A> xx = new ArrayList<B>();

both 'x' and 'xx' are legal declarations in Java 6 and Java 7 (I know that in Java 7 you can also substitute the parameterized type of the constructor with an empty set of type parameters (<>). However, I wonder, what is the difference between 'x' and 'xx' in Java 6?

2 Answers
Related