first value from Collection - Java java.util

Java examples for java.util:Collection Algorithm

Description

first value from Collection

Demo Code


//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();
    }
}

Related Tutorials