Hi, say i have a class and I create an array within the constructor in the class, and then i have a method and i want to add to the array in that method, how would I go about doing that? (my array is an array of Grade objects in a Grade support class i have made)
here is what i have been trying:
- public class GradeList {
-
-
public GradeList(int n) {
-
Grade[] grades= new Grade[n];
-
}
-
-
public void add(double max, double weight){
-
int i=0;
-
grades[i]=new Grade(max, weight);
-
//i get an error saying that variable grades cannot be found
-
i++;
-
}
-
}
Any help that would allow me to do what im trying to accomplish would be appreciated, thank you!