Here you can find the source of tail(List
public static List<String> tail(List<String> lines, int number)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> tail(List<String> lines, int number) { List<String> result = new ArrayList<String>(); int startpos = (lines.size() > number ? lines.size() - number : 0); if (lines.size() > number) { result.add("...(" + (lines.size() - number) + " lines skipped)..."); }//from w w w . java 2s .c o m for (int i = startpos; i < lines.size(); i++) { result.add(lines.get(i)); } return result; } }