Here you can find the source of getFirst(Iterable
Parameter | Description |
---|---|
iterable | a parameter |
T | a parameter |
public static <T> T getFirst(Iterable<T> iterable)
//package com.java2s; import java.util.Iterator; public class Main { /**// w ww .j ava2s . c o m * Method description * * * @param iterable * @param <T> * * @return * @since 1.5 */ public static <T> T getFirst(Iterable<T> iterable) { T result = null; if (iterable != null) { result = getFirst(iterable.iterator()); } return result; } /** * Method description * * * @param iterator * @param <T> * * @return * @since 1.5 */ public static <T> T getFirst(Iterator<T> iterator) { T result = null; if ((iterator != null) && iterator.hasNext()) { result = iterator.next(); } return result; } }