我正在尝试使用toString(int[])
方法,但我认为我的做法是错误的:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Arrays.html#toString(int[])
我的代码:
int[] array = new int[lnr.getLineNumber() + 1];
int i = 0;
System.out.println(array.toString());
输出结果为:
[I@23fc4bec
我也尝试过这样打印,但是:
System.out.println(new String().toString(array)); // **error on next line**
The method toString() in the type String is not applicable for the arguments (int[])
这段代码是我从更大更复杂的代码中摘出来的,但如果需要,我可以将其添加回去。不过这应该可以提供一般性信息。
我正在寻找输出结果,就像Oracle文档中提供的:
字符串表示由数组元素列表组成,用方括号("[]")括起来。相邻的元素用逗号和空格分隔(", ")。