Here you can find the source of getFirst(final Iterable
public static <T> T getFirst(final Iterable<T> iterable)
//package com.java2s; /*/* ww w.ja v a 2 s .co m*/ * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ import java.util.Iterator; public class Main { public static <T> T getFirst(final Iterable<T> iterable) { if (iterable == null) { return null; } final Iterator<T> iterator = iterable.iterator(); if (iterator == null) { return null; } return iterator.hasNext() ? iterator.next() : null; } }