簡體   English   中英

ArrayBoss 類型中的方法 (int[]) 不適用於參數 ()

[英]The method (int[]) in the type ArrayBoss is not applicable for the arguments ()

我正在創建一個類,該類具有一個接受整數的構造函數,並創建一個整數數組、雙精度數組和整數大小的字符數組。 我想在驅動程序類中測試我的代碼,但我不知道如何在我的 toString 方法中調用我的方法 StealIntegerArray。 我知道stealIntegerArray 方法中的代碼很可能是非常錯誤的,但我現在只需要知道如何調用該方法。 我收到錯誤“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(); 
}

你正在試圖調用stealIntegerArray()的方法中toString()方法,無需任何參數,但定義stealIntegerArray()方法期望的int[]數組引用(或null )作為參數。 根據你想要做什么,你可以這樣稱呼它:

stealIntegerArray(null);
stealIntegerArray(new int[10]);
stealIntegerArray(variableOfAnIntArray);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM