[英]The method (int[]) in the type ArrayBoss is not applicable for the arguments ()
I am working on creating a class that has a constructor that takes integers and creates an integer array, double array, and character array of the size of the integers.我正在创建一个类,该类具有一个接受整数的构造函数,并创建一个整数数组、双精度数组和整数大小的字符数组。 I would like to test my code as I go along in a driver class, but I cannot figure out how to call my method stealIntegerArray in my toString method.
我想在驱动程序类中测试我的代码,但我不知道如何在我的 toString 方法中调用我的方法 StealIntegerArray。 I understand that the code in the stealIntegerArray method is most likely very wrong, but I only need to know how to call on that method for now.
我知道stealIntegerArray 方法中的代码很可能是非常错误的,但我现在只需要知道如何调用该方法。 I am getting the error "The method stealIntegerArray(int[]) in the type ArrayBoss is not applicable for the arguments ()".
我收到错误“ArrayBoss 类型中的方法stealIntegerArray(int[]) 不适用于参数()”。
public class ArrayBoss
{
private int[] integerArray;
private int intArray;
public ArrayBoss(int i, int t, int c)
{
intArray = i;
int[] integerArray = new int[i];
}
public int[] stealIntegerArray(int[]
numArray)
{
numArray = integerArray;
numArray[0] = -1234;
return integerArray;
}
public String toString()
{
return stealIntegerArray();
}
You are trying to call the stealIntegerArray()
method in the toString()
method without any arguments, but the definition of the stealIntegerArray()
method expect an int[]
array reference (or null
) as an argument.你正在试图调用
stealIntegerArray()
的方法中toString()
方法,无需任何参数,但定义stealIntegerArray()
方法期望的int[]
数组引用(或null
)作为参数。 Depending on what you want to do you can call it like:根据你想要做什么,你可以这样称呼它:
stealIntegerArray(null);
stealIntegerArray(new int[10]);
stealIntegerArray(variableOfAnIntArray);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.