Get last item from List - Android java.util

Android examples for java.util:List Element

Description

Get last item from List

Demo Code


//package com.java2s;
import java.util.Collection;
import java.util.List;

public class Main {
    public static <T> T last(final List<T> c) {
        return isNullOrEmpty(c) ? null : c.get(c.size() - 1);
    }// ww w .ja  v a 2 s .co  m

    public static boolean isNullOrEmpty(final Collection<?> c) {
        return c == null || c.isEmpty();
    }
}

Related Tutorials