Skip to content

Instantly share code, notes, and snippets.

@cobratbq
Created April 29, 2016 19:53
Show Gist options
  • Save cobratbq/c7e98ec7311fe15ea33babff55c9d854 to your computer and use it in GitHub Desktop.
Save cobratbq/c7e98ec7311fe15ea33babff55c9d854 to your computer and use it in GitHub Desktop.
Naive implementation of summing-method
public class Test {
public static void main(String[] args) {
final ArrayList<Double> list = new ArrayList<>();
list.add(1.3);
list.add(1.4);
list.add(1.7);
list.add(2.3);
naiveSum(list);
}
public static void naiveSum(final ArrayList<Double> values) {
double sum = 0;
for (final double d : values) {
sum += d;
}
System.out.println(Double.toString(sum));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment