Here you can find the source of getLast(List
public static <T> T getLast(List<T> aList)
//package com.java2s; import java.util.*; public class Main { /**/*from www . j a v a 2s . c o m*/ * Returns the last object in the given list. */ public static <T> T getLast(List<T> aList) { return get(aList, size(aList) - 1); } /** * Returns the object at the given index (returns null object for null list or invalid index). */ public static <T> T get(List<T> aList, int anIndex) { return aList == null || anIndex < 0 || anIndex >= aList.size() ? null : aList.get(anIndex); } /** * Returns the size of a list (accepts null list). */ public static int size(List aList) { return aList == null ? 0 : aList.size(); } }