Java泛型转换为通配符规则

Java泛型转换为通配符规则,java,generics,wildcard,Java,Generics,Wildcard,在简单的情况下,我可以轻松地从泛型类型降级为通配符类型: List<Integer> intList = new ArrayList<>(); List<?> wildList = intList; // I can cast to a List<?> 然而,随着我的泛型变得越来越复杂: List<List<Integer>> nestedIntList = new ArrayList<>(); List<

在简单的情况下,我可以轻松地从泛型类型降级为通配符类型:

List<Integer> intList = new ArrayList<>();
List<?> wildList = intList; // I can cast to a List<?>
然而,随着我的泛型变得越来越复杂:

List<List<Integer>> nestedIntList = new ArrayList<>();
List<List<?>> nestedWildList = nestIntList; // This does not compile
有没有一种方法可以使其编译?我是否遗漏了编译器保护我的逻辑案例?为什么我不能铸造内部类型

列表可分配给列表或列表>

见: