更新时间:2022-01-02 01:35:55
旧行为不是错误,新行为也不是错误.条件表达式类型的规则变得更加复杂,这在很多情况下都有帮助,而对您的情况并没有真正的伤害.
Neither was the old behavior a bug, nor is the new behavior a bug. The rules for the type of the conditional expression just got more complex, which helps in many cases and doesn't really hurt in yours.
编译器不允许,因为Integer.class
和Float.class
的类型不可比.没有类型 T
会使 Class
成为 Class
和 Class
The compiler does not allow it because the types of Integer.class
and Float.class
are incomparable. There is no type T
which would make Class<T>
a supertype of both Class<Integer>
and Class<Float>
.