Here you can find the source of getFirst(List
public static <T> T getFirst(List<T> list)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static <T> T getFirst(List<T> list) { if (isEmpty(list)) { return null; }// w w w . j ava2 s . c o m return list.get(0); } public static boolean isEmpty(List<?> list) { return (list == null) || list.isEmpty(); } }