public class Test<V extends Number & Comparable> {
private V v;
public Test() {
Double s = 0.0;
v = (V) (Number) s;
}
public static void main(String[] args) {
Test T = new Test();
System.out.println(T.v);
}
}
Double和V都extends了Number,所以 Double s = 0.0; v = (V) (Number) s;转化但如果是两个类extends了Number是转化不了的,会报错java.lang.ClassCastException