泛型列表<字符串>和列表<整数>行为不符合预期
为什么打印“tom”并且在强制转换为 后未显示任何运行时异常,而在强制转换为 后无法打印值 1?printlnList<Integer>List<String>
import java.util.Arrays;
import java.util.List;
public class Main {
    public static void main(String args[]) {
        List list = Arrays.asList(1, "tom");
        System.out.println(((List<Integer>) list).get(1));
        // "tom"
        System.out.println(((List<String>) list).get(0));
        // ClassCastException: Integer cannot be cast to String
    }
}