1

我一直收到这个错误,但我不知道是什么原因造成的,有人可以帮我理解吗?

private int [] arrayFeeCode = new int [5];

/**
 * Constructor for objects of class Rally
 */
public Rally(int RC, String Venue, int NumDays, int MaxPlaces, int arrayFeeCode)
{
    // initialise instance variables


    arrayFeeCode[0] = 0.00;
    arrayFeeCode[1] = 10.00;
    arrayFeeCode[2] = 15.50;
    arrayFeeCode[3] = 17.75;
    arrayFeeCode[4] = 20.00;



}
4

5 回答 5

4

该参数在您的方法arrayFreeCode中声明为 an int,但您将其视为int[].

于 2013-03-22T14:42:36.057 回答
1

您是否将双打放在 int 数组中?您需要将整数放入其中。

于 2013-03-22T14:47:12.363 回答
0

您不能将 Double 放入整数数组中。

改变

private int [] arrayFeeCode = new int [5];

private double [] arrayFeeCode = new double [5];
于 2013-03-22T15:25:57.007 回答
0

更改参数arrayFeeCode

public Rally(int RC, String Venue, int NumDays, int MaxPlaces, double[] arrayFeeCode){
     arrayFeeCode[0] = 0.00;
     arrayFeeCode[1] = 10.00;
     arrayFeeCode[2] = 15.50;
     arrayFeeCode[3] = 17.75;
     arrayFeeCode[4] = 20.00;
}
于 2016-11-12T02:21:52.407 回答
-1
private double [] arrayFeeCode = new double [5];
public Rally(int RC, String Venue, int NumDays,int MaxPlaces,double[] arrayFeeCode)
{
    arrayFeeCode[0] = 0.00;
    arrayFeeCode[1] = 10.00;
    arrayFeeCode[2] = 15.50;
    arrayFeeCode[3] = 17.75;
    arrayFeeCode[4] = 20.00;
}
于 2018-11-11T18:58:16.743 回答