Skip to content

Instantly share code, notes, and snippets.

@elifry
Created October 3, 2021 21:47
Show Gist options
  • Save elifry/e262cc0a0d60405a49242f3053940740 to your computer and use it in GitHub Desktop.
Save elifry/e262cc0a0d60405a49242f3053940740 to your computer and use it in GitHub Desktop.
Java calculate average from arraylist
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