Java Collection First getFirstItemInCollection(Collection collection)

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

Description

get First Item In Collection

License

Apache License

Declaration

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

Method Source Code

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

import java.util.Collection;

public class Main {
    public static <T> T getFirstItemInCollection(Collection<T> collection) {
        //noinspection LoopStatementThatDoesntLoop
        for (T item : collection) {
            return item;
        }//from  w ww.  j  a v a 2 s .  c  o  m
        return null;
    }
}

Related

  1. getFirstElementOrNull(Collection collection)
  2. getFirstElementOrNull(Collection coll)
  3. getFirstItem(Collection c)
  4. getFirstItem(Collection collection)
  5. getFirstItem(Collection c)
  6. getFirstN(Collection objects, int n)
  7. getFirstNonNull(Collection c)
  8. getFirstNotNullValue(final Collection collection)
  9. getFirstOrNull(final Collection collection)