Java examples for java.util:Collection Compare
Returns the sum of the items of the given collection.
//package com.book2s; import java.util.Collection; public class Main { public static void main(String[] argv) { Collection c = java.util.Arrays.asList("asdf", "book2s.com"); System.out.println(sum(c)); }/*from ww w. j a va 2s . co m*/ /** * Returns the sum of the items of the given collection. */ public static float sum(Collection<Float> c) { float ret = 0; for (float i : c) ret += i; return ret; } }