java的打印与Arrays.toString阵列()错误 [英] java printing an array with Arrays.toString() error
问题描述
所以我尝试打印的int数组在我的计划,并按照这些指令的最简单的方法打印在Java中数组
写了下面的code:
INT []总访问量= //方法返回int数组
的System.out.println(Arrays.toString(总计));
但它不会编译说
类对象toString方法不能被应用到给定的类型。
要求:无参数
发现:INT []
原因:实际的和正式的参数列表的长度不同
块引用>为什么会这样?难道我没有通过我的数组作为参数传递给的toString?如果没有,我怎么使用的toString?
感谢您!
解决方案
类Object toString方法不能被应用到给定的类型。要求:未发现参数:INT []的原因:实际的和正式的参数列表的长度不同
块引用>可能是你有一个名为变量
阵列
,这就是为什么编译器抱怨你试图调用思维Object.toString()
,它不带任何参数。尝试
的System.out.println(java.util.Arrays.toString(总计));
So I was trying to print an array of ints in my program, and following these instructions Simplest way to print an array in Java
wrote the following code:
int[] totals = //method that returns int array System.out.println(Arrays.toString(totals));
But it wont compile saying that
"method toString in class Object cannot be applied to given types. required: no arguments found: int[] reason: actual and formal argument list differ in length"
Why does it do that? Do I not pass my array as an argument to toString? If not, how do I use toString?
Thank you!
解决方案method toString in class Object cannot be applied to given types. required: no arguments found: int[] reason: actual and formal argument list differ in length
May be you have a variable named
Arrays
, that's why the compiler is complaining thinking that you are trying to invoke theObject.toString()
, which doesn't take any argument.Try
System.out.println(java.util.Arrays.toString(totals));
这篇关于java的打印与Arrays.toString阵列()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!