Here you can find the source of getLastOrNull(List
public static <T> T getLastOrNull(List<T> l)
//package com.java2s; //it under the terms of the GNU Affero General Public License as published by import java.util.Collection; import java.util.List; public class Main { public static <T> T getLastOrNull(List<T> l) { final int size = l.size(); if (size == 0) return null; return l.get(size - 1); }/*from w w w . j a va 2 s . c o m*/ /** * @param coll * @postcondition (coll == null) --> (result == 0) * @postcondition (coll != null) --> (result == coll.size()) */ public static int size(Collection<?> coll) { return (coll == null) ? 0 : coll.size(); } }