Java List Tail tail(List list, int tailLength)

Here you can find the source of tail(List list, int tailLength)

Description

tail

License

Open Source License

Declaration

public static <E> List<E> tail(List<E> list, int tailLength) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static <E> List<E> tail(List<E> list, int tailLength) {
        if (tailLength <= 0)
            return Collections.emptyList();

        ArrayList<E> newList = new ArrayList<E>(list);
        if (tailLength < list.size())
            newList.subList(0, newList.size() - tailLength).clear();
        return newList;
    }/*w w w. j a v  a 2 s  . c o  m*/
}

Related

  1. tail(final List list)
  2. tail(List list)
  3. tail(List lines, int number)
  4. tail(List lst, int from)
  5. tail(List l)
  6. tail(List list)