Java Collection First getFirst(Collection c)

Here you can find the source of getFirst(Collection c)

Description

Returns the first element in a collection (according to its iterator).

License

Open Source License

Exception

Parameter Description

Declaration

public static Object getFirst(Collection c) 

Method Source Code

//package com.java2s;

import java.util.Collection;

public class Main {
    /**/*  w  w  w  . j  a v a2 s.c om*/
     * Returns the first element in a collection (according to its iterator).
     * 
     * @throws java.util.NoSuchElementException
     *           if collection is empty.
     */
    public static Object getFirst(Collection c) {
        return c.iterator().next();
    }
}

Related

  1. firstNonNull(Collection collection)
  2. firstOrThat(Collection collection, T that)
  3. firstValue(Class type, Collection values)
  4. GET_FIRST_ELEMENT(Collection coll)
  5. getCollectionFirstElement( final Collection collection)
  6. getFirst(Collection c)
  7. getFirst(Collection collection)
  8. getFirst(Collection bag)
  9. getFirst(Collection c)