Created
October 3, 2021 21:47
-
-
Save elifry/e262cc0a0d60405a49242f3053940740 to your computer and use it in GitHub Desktop.
Java calculate average from arraylist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double calculateAverage(ArrayList<Integer> list) { | |
double sum = 0; | |
for (Integer elem : list) { | |
sum += elem; | |
} | |
sum = sum / list.size(); | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment