Java examples for Collection Framework:List
Returns the last element of a list.
//package com.java2s; import java.util.List; public class Main { /**/*from www .jav a2 s .c o m*/ * Returns the last element of a list. * * @param <T> Type of the objects in the input list. * @param list The input list. * * @return The last element of the input list. */ public static <T> T last(final List<T> list) { return list.get(list.size() - 1); } }