Java examples for java.util:Collection Algorithm
first value from Collection
//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(first(list)); }/*from w w w.ja va2s. c o m*/ public static Number first(Collection<Number> list) { return list.iterator().next(); } }