How to calculate average of array in Java?

Ads
Ads

How to calculate average of array in Java?


Java Coder
How to calculate average of array in Java?
1 Answer(s)      a year and a month ago
Posted in : Java Beginners
Ads

Hi,

I have an integer array and I want to calculate the average of the values in it.

How to calculate average of array in Java?

Thanks

View Answers

April 16, 2017 at 7:45 PM


Hi,

You can iterate through the elements of array and then calculate sum. Then divide it with the length of the array.

This way you can achieve the result.

Check source code at Average of Array.

Thanks


Ads