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 list)
{
int sum = 0;
for(int element : list)
sum += element;
return (sum/list.size());
}
```

Computer Science & Information Technology

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

Computer Science & Information Technology

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?

Computer Science & Information Technology

The compiler automatically converts any array subscript used by a programmer to an equivalent ____ expression.

a. reference b. pointer c. class d. object

Computer Science & Information Technology

?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

Computer Science & Information Technology