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 last(final List<T> c) { return isNullOrEmpty(c) ? null : c.get(c.size() - 1); } public static boolean isNullOrEmpty(final Collection<?> c) { return c == null || c.isEmpty(); } }