user2199680
user2199680

Reputation: 41

java array error "array required but int found"

i keep recieving this error but i dont know whats causing it, could someone please help me understand ?

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;



}

Upvotes: 1

Views: 36089

Answers (5)

Gamers Stop
Gamers Stop

Reputation: 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;
}

Upvotes: -1

Change the parameter arrayFeeCode

to

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;
}

Upvotes: 0

Hafizh Herdi
Hafizh Herdi

Reputation: 180

You can't put Double into an array of Integer.

Change

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

To

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

Upvotes: 0

Emil Iakoupov
Emil Iakoupov

Reputation: 189

Are you putting doubles in int array? You need to put ints in it.

Upvotes: 1

akaIDIOT
akaIDIOT

Reputation: 9231

The parameter arrayFreeCode is declared as an int in your method, yet you treat it as an int[].

Upvotes: 4

Related Questions