Generic notation <?> and < ? extends Object > behaving differently

Viewed 225

To my understanding, <? extends Object> and <?> are same.

However, when I run the following code <? extends Object> does not get compiled and is working as expected but <?> is getting compiled successfully.

public class Test1 
{
    interface I1 
    {
    }

    interface I2<T extends I1> extends Comparable<I2<?>> 
    {
        Comparator<I2<? extends I1>> A = null;
        //Comparator<I2<? extends Object>> B = A; // expected compilation fail
        Comparator<I2<?>> B = A; // compiling successfully.This shouldn't get compile
    }
}

Can some one help me understand this behavior.

2 Answers
Related