Как получить ссылку на дочерний универсальный тип из родительского универсального типа?JAVA

Программисты JAVA общаются здесь
Anonymous
Как получить ссылку на дочерний универсальный тип из родительского универсального типа?

Сообщение Anonymous »


here is the scenario

class MyClass1{ } class MyClass2 extends MyClass1{ } class Parent{ List list; } class Child extends Parent{ } this doesn't compile

Parent p = new Child(); this does

Parent p = new Child(); why?

is there a way to refer via parent type?


Источник: https://stackoverflow.com/questions/288 ... neric-type

Вернуться в «JAVA»