简体   繁体   English

ArrayBoss 类型中的方法 (int[]) 不适用于参数 ()

[英]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.

相关问题 类型中的方法不适用于参数(int) - The method in the type is not applicable for the arguments (int) main类型的方法(double [])不适用于参数(int []) - The method (double[]) in the type main is not applicable for the arguments (int[]) 类型X中的方法X不适用于参数(int) - The method X in the type X is not applicable for the arguments (int) prosedure_jsp类型的pro(int,int)方法不适用于参数() - The method pro(int, int) in the type prosedure_jsp is not applicable for the arguments () Arrays 类型中的 asList(T[]) 方法不适用于参数 (int, int) - The method asList(T[]) in the type Arrays is not applicable for the arguments (int, int) PreparedStatement 类型中的 setString(int, String) 方法不适用于参数 (int, String[]) - The method setString(int, String) in the type PreparedStatement is not applicable for the arguments (int, String[]) FragmentTransaction类型的方法add(int,Fragment)不适用于参数(int,WeatherFragment) - The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, WeatherFragment) BufferedImage类型的方法getRGB(int,int)不适用于参数(..) - The method getRGB(int, int) in the type BufferedImage is not applicable for the arguments (..) 类型中的方法不适用于参数 - The method in the type is not applicable for the arguments 类型中的方法不适用于参数 - Method in the type is not applicable to the arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM