如何使用构造函数和类正确打印数组?JAVA
我只是想让数组正确打印。这就是我目前所拥有的如何使用构造函数和类正确打印数组?JAVA,java,arrays,printing,constructor,Java,Arrays,Printing,Constructor,我只是想让数组正确打印。这就是我目前所拥有的 public class Driver { public static void main(String[] args) { //create new instance of the ArrayLab class with parameter of 10 ArrayClass array = new ArrayLab(10); array.initialize(); } 我确实意识
public class Driver
{
public static void main(String[] args)
{
//create new instance of the ArrayLab class with parameter of 10
ArrayClass array = new ArrayLab(10);
array.initialize();
}
我确实意识到我的类有一个参数,无论我是否在java数组字段中有一个简单的实例变量和class参数,问题都是一样的
它都可以编译,但我遇到的问题是,当它打印输出时,会出现类似这样的情况[I@1443957.这意味着什么?尝试用下一种方式打印:
System.out.println(Arrays.toString(array));
ArrayClass
的构造函数必须是namesArrayClass
而不是ArrayLab
…已修复,仍然相同的问题找不到符号-变量数组。@pewpew您应该导入数组类:“import java.util.Arrays;”在类定义的开头它起作用了!谢谢:)@pewpew accept答案就足够了。:)这怎么不在oracle文档中?或者我是瞎子?
System.out.println(Arrays.toString(array));