标签: java arrays list types variable-assignment
Object[] o = new Object[3]; String[] s = new String[3]; o = s; //compiles o[0] = new Date(); List<Object> o2 = new ArrayList<>(); List<String> s2 = new ArrayList<>(); o2 = s2; //does not compile
我不明白为什么第一个代码块o=s;正确编译,而o2=s2;的分配错误。
o=s;
o2=s2;