Here you can find the source of firstOrDefault(Iterator
public static <T> T firstOrDefault(Iterator<T> iterator)
//package com.java2s; //License from project: BSD License import java.util.Iterator; public class Main { public static <T> T firstOrDefault(Iterator<T> iterator) { if (!iterator.hasNext()) { return null; }// w ww. j ava 2 s. co m return iterator.next(); } }