Can you set the size of the array in the modifier method? I have it like this and I get an error.
Code://Data Field
private double[] scoresArray;
// Modifier Methods
public void setScoresArray(int j) {
this.scoresArray[j];
}
Printable View
Can you set the size of the array in the modifier method? I have it like this and I get an error.
Code://Data Field
private double[] scoresArray;
// Modifier Methods
public void setScoresArray(int j) {
this.scoresArray[j];
}
If You want to create instance of Array object, You should say:
Code:this.scoresArray = new double[j];
Yes you can.
But not like that. That's not how you initialize an array, but rather you'd do something like so to initialize one, right?:Quote:
I have it like this and I get an error.
Code://Data Field
private double[] scoresArray;
// Modifier Methods
public void setScoresArray(int j) {
this.scoresArray[j];
}
Or if myArray is declared elsewhere as happens in your example:Code:int[] myArray = new int[10];
Code:myArray = new int[10];
You're missing all of this.
I got ya. Thanks both of you!!