i know i'm now loosing the plot over this so any rapid help will be appreciated!
i have to write a method which calculates the average from numbers contained in a list, when i try and run the code i get the error message:
Semantic error: Cannot reach instance method: average( java.util.List ) from static context: Student
the code for the average() method is:
/**
* calculates the average
*/
public int average(List<Integer> userData)
{
int total = 0;
for (int eachElement : userData)
{
total = total + eachElement;
}
int avg = ((int)total) / userData.size();
System.out.println("average = " + avg);
return avg;
}
i've been given the following two lines to test this works
Integer[] numberArray = {75, 59, 0, 70};
Student.average(Arrays.asList(numberArray));
but when i try to execute these two lines in my test enviroment i get the error message??
anyone??