【发布时间】:2012-09-27 17:05:56
【问题描述】:
public class RefMix {
public static void main(String[] args) {
Object[] a = {null, "foo"};
Object[] b = {"bar", b};
a[0] = b;
System.out.println(a[0][0]);
}
}
我的理解是数组是 Java 中的对象,因此是 Object 类型的子类。我的进一步理解是 2-dim 数组是作为数组引用的数组实现的。因此我不明白为什么我的 a[0][0] 在上面的代码中没有产生bar。相反,它不会编译:
RefMix.java:7: array required, but java.lang.Object found
【问题讨论】: