Hi Guys , I am rather new to Java and I am trying to extend the ArrayList object to that when an ArrayList of Integers exists it has a function to return the Average value of the Integers within the ArrayList. Below is the code I have so far:
import java.util.*;*
*import java.lang.*;
public class MathArrayList<Integer> extends ArrayList<Integer> {
double average;
public double Average() {
CalculateAverage();
return average;
}
private void CalculateAverage() {
double total = 0;
for(int i = 0; i < size(); i++) {
total += get(i).intValue();
}
average = total / size();
}
}
When I attempt to compile this code I get: Cannot find symbol - Line 18 - ".intValue()" and I cannot work out why! I have created a smaller java project to test that I am using the method '.intValue()' correctly and it is converting and Integer to an int fine! Why cannot it not find a symbol?
Any help/comments if much appricated!
Thanks, Stewart