Java Collection First getFirst(Collection collection)

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

Description

get First

License

Apache License

Declaration

public static <T> T getFirst(Collection<T> collection) 

Method Source Code


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

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static <T> T getFirst(Collection<T> collection) {
        if (collection != null) {
            Iterator<T> iterator = collection.iterator();
            return iterator.hasNext() ? iterator.next() : null;
        }/*from  w w  w.j a v a2  s .c o  m*/

        return null;
    }
}

Related

  1. getFirst(Collection bag)
  2. getFirst(Collection c)
  3. getFirst(Collection col)
  4. getFirst(Collection coll)
  5. getFirst(Collection collection)
  6. getFirst(Collection collection)
  7. getFirst(Collection collection)
  8. getFirst(Collection collection)
  9. getFirst(Collection collection)