# Java 8 program to calculate average of N numbers

In this example, we will see “How to calculate average of N numbers in Java 8?”. To achieve that, we are going to use Stream API introduced in Java 8 to find average and we will see it through several different ways.

In this tutorial, we are going to cover below topics:

Let’s begin:

### 1. How to calculate average of N numbers?

It’s very easy to find out the average. Average has been calculated as sum of n numbers divided by n.

In order to calculate average, add all the numbers and divide them by count of numbers

Let’s take an example,

There are following numbers available: 7, 10, 81, 33, 69

And, we need to find the average of these numbers, what we need to do is:

a. First add all the numbers: (7+10+81+33+69) =  200

b. Count the numbers: (7,10,81,33,69) = 5

c. Find average by dividing a from b: 200 / 5 = 40

Output:

Output:

## Example 3. Java 8 code to find average of numbers using Array with Scanner

Output:

Do you like this Post? – then check my other helpful posts:

### Related Posts:

[wcp-carousel id=”5342″]

### Promotional Content: 