Java examples for java.util:Collection Algorithm
last value from Collection
//package com.java2s; import java.util.Collection; public class Main { public static void main(String[] argv) throws Exception { Collection list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(last(list)); }//ww w.java 2s . co m public static Number last(Collection<Number> list) { return (Number) list.toArray()[list.size() - 1]; } }