Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { public static long getSum(Collection<? extends Number> collection) { Iterator<? extends Number> iterator = collection.iterator(); long sum = 0; while (iterator.hasNext()) { sum += iterator.next().longValue(); } return sum; } }