更新时间:

#java list坑

static void test(List<String>... stringLists) {
 Object[] array = stringLists; //变量指向 stringLists
 List<Integer> tmpList = Arrays.asList(42);
 array[0] = tmpList; // Semantically invalid, but compiles without warnings
//这里 stringlist 已经变成 tmpList 了
 String s = stringLists[0].get(0); // Oh no, ClassCastException at runtime! 实际是42
//  java.lang.Integer cannot be cast to java.lang.String
 System.out.println(s);// 错误
}