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.*;

public class Main {

    public static <T> T getFirst(Collection<T> collection) {
        if (isEmpty(collection)) {
            return null;
        }//from  w  w w . j  a v a 2  s. c o  m

        return collection.iterator().next();
    }

    public static boolean isEmpty(Collection collection) {
        return ((collection == null) || collection.isEmpty());
    }
}

Related

  1. getFirst(Collection coll)
  2. getFirst(Collection collection)
  3. getFirst(Collection collection)
  4. getFirst(Collection collection)
  5. getFirst(Collection collection)
  6. getFirst(Collection collection)
  7. getFirst(Collection l)
  8. getFirst(Collection set)
  9. getFirst(Collection set, boolean remove)