Java 为什么Array.toString或Array.deepToString不工作?

Java 为什么Array.toString或Array.deepToString不工作?,java,multidimensional-array,Java,Multidimensional Array,我正在测试如何打印阵列。我可以使用for loop打印它,但当我尝试使用数组时,toString或数组。deepToString就是不起作用。这里有一个例子 package Week4; import java.util.Arrays; public class prac2 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub

我正在测试如何打印阵列。我可以使用
for loop
打印它,但当我尝试使用
数组时,toString
数组。deepToString
就是不起作用。这里有一个例子

  package Week4;
  import java.util.Arrays; 
  public class prac2 {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub
     String[][] array = new String[][] { 
                { "Elem11", "Elem12", "Elem13" }, 
                { "Elem21", "Elem22", "Elem23" },
                { "Elem31", "Elwm32", "Elem33" } };
            System.out.println(Arrays.deepToString(array));
}
}


我正在使用JRE1.8.020。这和图书馆有关吗?我正在使用eclipse

我认为您使用的是IDE,它没有正确安装或软件包不完整

1. i ran your code in my IDE

2. import java.util.Arrays;

3. since you still have error i press `ctrl` then hover to `import java.util.Arrays;` which leads me to the `Arrays.class`

4. look to the hierarchy of the packages and looked where it came from `rt.jar` which contains all of the compiled class files for the base Java Runtime environment.

方法名称没有大写。尝试
deepToString
而不是
deepToString
。是的,我知道,但问题是(数组)无法识别。它提供了快速修复您是否为
java.util.array
添加了
import
语句?我刚刚运行了您的代码,它工作正常。我只是
import java.util.Arrays
@user2775042尝试下载rt.jar,然后将其添加到构建路径下载rt.jar并放入构建路径。现在它正在工作。谢谢
1. i ran your code in my IDE

2. import java.util.Arrays;

3. since you still have error i press `ctrl` then hover to `import java.util.Arrays;` which leads me to the `Arrays.class`

4. look to the hierarchy of the packages and looked where it came from `rt.jar` which contains all of the compiled class files for the base Java Runtime environment.