提供给定Iterable的第一项。
/** 来 自 n o w j a v a . c o m **/ //package com.nowjava; import java.util.Iterator; public class Main { /** * Provides the first item of the given list. * * @param list the list. May be <code>null</code>. * @return the first list item or <code>null</code> if the list was empty or <code>null</code>. */ public static <T> T firstItem(Iterable<T> list) { if (list != null) { Iterator<T> i = list.iterator(); if (i.hasNext()) {