Java Collection First firstElement(Collection c)

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

Description

first Element

License

Apache License

Declaration

public static <T> T firstElement(Collection<T> c) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;

public class Main {

    public static <T> T firstElement(Collection<T> c) {
        if (c != null && !c.isEmpty()) {
            return c.iterator().next();
        }//from   ww w  .  j a v  a  2 s .  co m
        return null;
    }
}

Related

  1. first(Collection c)
  2. first(Collection c)
  3. first(Collection collection)
  4. first(Collection collection)
  5. firstElement(Collection in)
  6. firstElementOf(final Collection collection)
  7. firstElementOf(final Collection items)
  8. firstFrom(Collection collection)
  9. firstFrom(Collection coll)