public class MainTest {public static void main(String[] args){
List<Integer> a = (List<Integer>)func();
System.out.println(a);
}
public static List func(){
List<String> ret = new ArrayList<String>();
ret.add("hello");
return ret;
}
}最后竟然能输出[hello]
为什么不会提示报错呢?是不是如上的类型转换只会检查最外层的类型List?
慕森王
慕村9548890
拉风的咖菲猫
相关分类