Here you can find the source of getFirst(final Collection
public static <T> T getFirst(final Collection<T> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static <T> T getFirst(final Collection<T> collection) { return collection == null ? null : collection.iterator().next(); }//from w ww .ja va 2s . co m }