SnsEntity
来自Entity
类
为什么?
List<DruidEntity<SnsEntity>>
与List<DruidEntity<?>>
如何使用通用参数。
还有没有更好的主意使用返回通用类型而不是<T> T
?
public class DruidEntity<T extends Entity> {
}
public class SnsEntity extends Entity {
}
public class Entity {
}
// Main Class
{
public <T> T test(List<DruidEntity<? extends Entity>> list) {
return some druidentity<snsEntity> object
}
List<DruidEntity<SnsEntity>> snsList = 'some list...'
DruidEntity<SnsEntity> = test(snsList) // <--- Why there is the error??
}
the compile error is List<Druidentity<SnsEntity>> is not compatible with List<DruidEntity<?>>