Here you can find the source of first(List
public static <T> T first(List<T> list)
//package com.java2s; import java.util.*; public class Main { public static <T> T first(List<T> list) { if (list == null || list.isEmpty()) throw new IllegalArgumentException("List is empty"); return list.get(0); }/*w ww . ja va 2s .co m*/ }