Что будет выведено на экран в результате компиляции и выполнения следующего кода?

public class Test<M> {

    <M> Class getArgumentClass(M m) {

        return m.getClass();
    }
    
    public static void main(String[] args) {

        Test test = new Test();
        
        Double d = new Double(12);

        Class c1 = test.<Double>getArgumentClass(d);
        Class c2 = test.<Number>getArgumentClass(d);
        Class c3 = test.getArgumentClass(d);
        
        System.out.println(c1 == c2);
        System.out.println(c1 == c3);
        System.out.println(c2 == c3);
    }
}
Explanation
В JSE7 проблема исправлена. Код выполняется без ошибок и выдаёт "true true true". Вместо "Unresolved compilation problems: The method getArgumentClass(Object) of raw type Test is no longer generic; it cannot be parameterized with arguments" компилятор выдаёт предупреждение "Type safety: The method getArgumentClass(Object) belongs to the raw type Test. References to generic type Test<m> should be parameterized"

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты