Here you can find the source of getLast(List
@SuppressWarnings("unchecked") public static <T> T getLast(List<T> list)
//package com.java2s; //License from project: Apache License import java.util.Deque; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static <T> T getLast(List<T> list) { if (list instanceof Deque) { return ((Deque<T>) list).getLast(); }//from ww w . java2s . c o m return list.get(list.size() - 1); } }