Here you can find the source of getFirstElement(List
public static <T> T getFirstElement(List<T> list)
//package com.java2s; import java.util.List; public class Main { public static <T> T getFirstElement(List<T> list) { if (list != null && list.size() >= 1) { return list.get(0); }/*from ww w .j ava 2 s . c o m*/ return null; } }