For example:

```
int [] numbers = {5, 8, 12, -18, -54, 84, -35, 17 , 37};
```

How to find the average?

What algorithm, or maybe there are special functions for this?

## Answer 1, Authority 100%

Algorithm itself, which works for all Java versions:

```
// average arithmetic - the sum of all numbers divided by their number
int [] numbers = {5, 8, 12, -18, -54, 84, -35, 17, 37};
Double average = 0;
if (numbers.length & gt; 0)
{
Double Sum = 0;
For (int j = 0; j & lt; numbers.length; j ++) {
SUM + = Numbers [j];
}
average = sum / numbers.length;
}
```

## Answer 2, Authority 125%

Well for example :

```
intstream.of (numbers) .AVerage ();
```

This is Java 8, Stream API. Check: http://ideone.com/hsng8i

## Answer 3, Authority 100%

```
optionalDouble average = arrays.stream (Numbers) .AVerage ();
```

## Answer 4

```
class avarage {
Public Static Void Main (String Args []) {
INT NUM [] = {5, 8, 12, -18, -54, 84, -35, 17, 37};
Double Sum = 0;
For (int x: num) {
SUM + = X;
}
System.out.Print ("The average arithmetic numbers is:" + sum / num.length);
}
}
```