Closed. This question is not reproducible or was caused by typos。它当前不接受答案。












想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。

5年前关闭。





我正在测试如何打印阵列。我可以使用for loop进行打印,但是当我尝试使用Arrays.toStringArrays.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));
}


}

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Arrays cannot be resolved

at Week4.prac2.main(prac2.java:14)


我正在使用JRE1.8.0_20。这和图书馆有关吗?我正在使用日食。

最佳答案

我认为您使用的是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.

关于java - 为什么Array.toString或Array.deepToString不起作用? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25635583/

10-10 17:04