Write a Java method named average. The method should take an ArrayList of Integers as a parameter, compute the average of the elements in the ArrayList and return the average to the calling method.
What will be an ideal response?
```
public static int average(ArrayList
{
int sum = 0;
for(int element : list)
sum += element;
return (sum/list.size());
}
```
You might also like to view...
Which of the following is not one of the “Five A’s” of information security?
A) Availability B) Assurance C) Authorization D) Authentication
In PL/SQL what is a Cursor? When do we use an explicit Cursor? What do you do when you declare a Cursor?
What will be an ideal response?
The compiler automatically converts any array subscript used by a programmer to an equivalent ____ expression.
a. reference b. pointer c. class d. object
?For longer video clips, the time in the cue is written in the form _____.
A. ?hh:mm:ss.ms B. ?hh.ms:ss C. ?hh.mm.ss D. ?ms:ss.mm:hh