Here you can find the source of firstOrNull(SortedSet
public static <T> T firstOrNull(SortedSet<T> set)
//package com.java2s; //License from project: Apache License import java.util.SortedSet; public class Main { public static <T> T firstOrNull(SortedSet<T> set) { if (set == null || set.isEmpty()) { return null; }/* w w w.ja va2 s . co m*/ return set.first(); } }