Code example for Collection

Methods: isEmpty, iterator

0
     * @return first element from the provided collection or <code>null</code> if the 
     *         collection is <code>null</code> or empty. 
     */ 
    public static <T> T getFirst(Collection<T> collection)
    { 
        if (collection == null || collection.isEmpty())
        { 
            return null; 
        } 
 
        return collection.iterator().next();
    } 
}