Here you can find the source of firstElementOrNull(Iterable iterable)
public static <K> Object firstElementOrNull(Iterable iterable)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { public static <K> Object firstElementOrNull(Iterable iterable) { Iterator iterator = iterable.iterator(); if (iterator.hasNext()) { return iterator.next(); } else {//from w w w . jav a2 s . c o m return null; } } }