How to calculate average of array in Java?

How to calculate average of array in Java?

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









Related Tutorials/Questions & Answers:
How to calculate average of array in Java?
How to calculate the average in Hibernate?
Advertisements
calculate average
calculate average
Calculate sum and Average in java
Average of Array
Calculate an average Age of my Class?
difference between java5 and java6 - Java Beginners
calculate size of array
Java2
array average across column
Find in Array - Calculate Occurrences of Elements in Array
about java1
how to print the average of each column of 2d n*m array using java
Javah
C calculate sum of first and last element of array
javaa swings - IDE Questions
How to calculate attending hours?
How to calculate days in a year
About Java2
how to calculate the price on the option box
Average
how to calculate EMI of the loan
How to calculate area of rectangle
Javap Tool application
How to calculate Date Difference in Java?
how to calculate the employee tax - JSP-Servlet
How to calculate sum of HH:MM:SS Format?
how to calculate max and min - RUP
javas - JSP-Servlet
how to write weighted moving average code using 2d-array
how to calculate max and min in the loop - Java Beginners
ModuleNotFoundError: No module named 'javax'
ModuleNotFoundError: No module named 'javax'
how to calculate salary of all the employees 10%extra then actual salary - SQL
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,
How to calculate number of weeks in a specified month
Get Array Size
How to calculate area of triangle
Maven dependency for com.gooddata - gooddata-http-client version 1.0.0+java7 is released. Learn to use gooddata-http-client version 1.0.0+java7 in Maven based Java projects
How to: generic array creation
MySQL Average Command
Artifacts of javax
How to Prepend Array in PHP
How to Convert ArrayList to Array?
Javah -  Header File Generator
how to create array in r
How to declare array in Java?
Determine Average by removing Largest and Smallest Number

Ads