Java List Last Item getLastOrNull(List l)

Here you can find the source of getLastOrNull(List l)

Description

get Last Or Null

License

Open Source License

Declaration

public static <T> T getLastOrNull(List<T> l) 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Affero General Public License as published by

import java.util.Collection;

import java.util.List;

public class Main {
    public static <T> T getLastOrNull(List<T> l) {
        final int size = l.size();
        if (size == 0)
            return null;
        return l.get(size - 1);
    }/*from  w  w  w  . j a va 2 s  . c  o m*/

    /**
     * @param coll
     * @postcondition (coll == null) --> (result == 0)
     * @postcondition (coll != null) --> (result == coll.size())
     */
    public static int size(Collection<?> coll) {
        return (coll == null) ? 0 : coll.size();
    }
}

Related

  1. getLastBefore(List list)
  2. getLastDateFromTimeSeriesDeltas(Double xAxisStart, List xAxisDeltas)
  3. getLastElement(List list)
  4. getLastNameIndex(List list)
  5. getLastNonNullIndex(final List list)
  6. getLastOrNull(List list)
  7. getLastSectionDays(List sections)
  8. getLastXItems(int lastXItems, List list)
  9. isLast(List list, Object o)