How to calculate average of array in Java?

 
 

Share on Google+Share on Google+

Java Coder
How to calculate average of array in Java?
1 Answer(s)      8 months 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

Ads
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









Ads

 
Advertisement null

Ads