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

public class Main {

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

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

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

    @SuppressWarnings("rawtypes")
    public static boolean isEmpty(Map map) {
        return (map == null) || map.isEmpty();
    }
}

Related

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