Java examples for java.util:List First Element
Return a List without the First Element
//package com.java2s; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static <T> T[] withoutFirst(T[] o) { final Class<?> memberClass = o.getClass().getComponentType(); final T[] result = (T[]) Array.newInstance(memberClass, o.length - 1);//from w w w .ja va 2 s .c o m System.arraycopy(o, 1, result, 0, result.length); return result; } public static <T> List<T> withoutFirst(List<T> o) { final List<T> result = new ArrayList<T>(); for (int i = 1; i < o.size(); i++) result.add(o.get(i)); return result; } }