Java Utililty Methods List Tail

List of utility methods to do List Tail

Description

The list of methods to do List Tail are organized into topic(s).

Method

Listtail(final List list)
tail
return drop(list, 1);
Listtail(List list)
tail
List result = new ArrayList<>(list);
result.remove(0);
return Collections.unmodifiableList(result);
Listtail(List list, int tailLength)
tail
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;
Listtail(List lines, int number)
tail
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)...");
for (int i = startpos; i < lines.size(); i++) {
    result.add(lines.get(i));
return result;
Listtail(List lst, int from)
Gets tail of the list
return lst.subList(Math.max(0, Math.min(from, lst.size())), lst.size());
Listtail(List l)
Returns the tail of the provided List i.e. the sublist which contains all elements of the given list except the #head(List) head .
if (l.isEmpty()) {
    throw new UnsupportedOperationException("Cannot get tail of empty list.");
} else {
    return l.subList(1, l.size());
Listtail(List list)
Returns a sublist containing all the items in the list after the first
if (list.isEmpty())
    return Collections.emptyList();
else
    return list.subList(1, list.size());
Listtail(List list)

tail

return list.subList(1, list.size());
Listtail(List list)
tail
List<T> tail = new ArrayList<>(list);
tail.remove(head(list));
return tail;
Listtail(List list)
tail
return list.subList(1, list.size());