Here you can find the source of trimSequence(int m, List
public static List<String> trimSequence(int m, List<String> sequence)
//package com.java2s; //License from project: Open Source License import java.util.*; import java.util.List; public class Main { public static List<String> trimSequence(int m, List<String> sequence) { List<String> result = new ArrayList<String>(); for (int i = sequence.size() - 1; result.size() < m; i--) { result.add(0, sequence.get(i)); }//from w w w . j a va2 s.c o m assert result.size() == m; assert result.get(result.size() - 1).equals(sequence.get(sequence.size() - 1)); return result; } }