Here you can find the source of getLastOfCollection(Collection
@SuppressWarnings("unchecked") public static <T> T getLastOfCollection(Collection<T> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { @SuppressWarnings("unchecked") public static <T> T getLastOfCollection(Collection<T> collection) { T t = (T) collection.toArray()[collection.size() - 1]; return t; }/*from ww w . j a v a2s . c o m*/ }