Java tutorial
//package com.java2s; import java.util.*; public class Main { /** * Get the first item in a list. If there is no such item, return * null. */ public static <T> T first(Collection<T> list) { if (list == null || list.isEmpty()) return null; return list.iterator().next(); } }