Here you can find the source of getlast(final T[] array)
Parameter | Description |
---|---|
array | an array (may be null or empty) |
array
if any, null
otherwise.
public static <T> T getlast(final T[] array)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**//from w ww. j a v a 2s . c o m * @param array an array (may be null or empty) * @return the last element of <code>array</code> if any, <code>null</code> otherwise. */ public static <T> T getlast(final T[] array) { return array == null || array.length == 0 ? null : array[array.length - 1]; } /** * @param list a list (may be null or empty) * @return the last element of <code>list</code> if any, <code>null</code> otherwise. */ public static <T> T getlast(List<T> list) { return list == null || list.size() == 0 ? null : list.get(list.size() - 1); } }