public static <T> T last(List<T> lst) {
        if (lst == null || lst.isEmpty()) return null;
        return lst.get(lst.size() - 1);
    }
public static < T > T last ( List < T > lst ) { if ( lst == null || lst . isEmpty ( ) ) return null ; return lst . get ( lst . size ( ) - 1 ) ; }
Returns the last element of a list, or null if empty.
@param lst   the list
@param <T>   element type
@return last element or null