Here you can find the source of getLast(List
public static <V> V getLast(List<V> list)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static <V> V getLast(List<V> list) { return getLast(list, null); }//from w w w . j av a2 s. c o m public static <V> V getLast(List<V> list, V defaultValue) { int size = list.size(); if (size > 0) { return list.get(size - 1); } else { return defaultValue; } } public static <V> V get(List<V> list, int index, V defaultValue) { try { return list.get(index); } catch (Exception ignore) { } return defaultValue; } }