我正在尝试创建一个 Java 对象数组并将数组本身放在其第二个索引处(以便用数组表示自相似分形),但是当我尝试访问时theArray[1][1][0]
,我收到此错误:
Main.java:11: error: array required, but Object found
.
到目前为止,这是我尝试过的,我不确定为什么它不起作用:
import java.util.*;
import java.lang.*;
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Object[] theArray = new Object[2];
theArray[0] = "This array should contain itself at its second index.";
theArray[1] = theArray; //Now I'm attempting to put the array into itself.
System.out.println(theArray[1][1][0]) //Main.java:11: error: array required, but Object found
}
}
正如我在这里尝试做的那样,实际上是否可以在其内部放置一个 Java 数组?