I am trying to create a method which calculates the total sum of all the elements in array scores. When I compile this I get a "Variable may not have been initialized error" even though I've already declared it within the method
public double getTotal() {
double total;
for(int i=0;i<scores.length;i=i+2) {
total = scores[i] + scores[i+1];
}
return total;
}