Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.List; public class Main { public static <T> T first(List<T> list) { return isNullOrEmpty(list) ? null : list.get(0); } public static boolean isNullOrEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } }