Java examples for java.util:List First Element
Get the last value from a List
//package com.java2s; import java.util.List; public class Main { public static void main(String[] argv) { List list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(last(list)); }/*from w w w . ja v a 2 s. com*/ public static <A> A last(List<A> list) { return list.isEmpty() ? null : list.get(list.size() - 1); } }