Java tutorial
//package com.java2s; import java.util.List; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; public class Main { public static <T> List<T> trim(List<T> list, int count) { List<T> result = Lists.newArrayList(list); for (int i = 0; i < count && result.size() > 0; i++) { int idx = result.size() - 1; result.remove(idx); } return ImmutableList.copyOf(result); } }