Java examples for java.util:Collection Algorithm
min value from Collection of Number
//package com.java2s; import java.util.Collection; public class Main { public static void main(String[] argv) throws Exception { Collection list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(min(list)); }/* w w w . j a v a 2 s.c om*/ public static Number min(Collection<Number> list) { Number min = list.iterator().next(); for (Number item : list) { if (item.floatValue() < min.floatValue()) { min = item; } } return min; } }