Here you can find the source of shiftElementsToEnd(final List
public static <T> List<T> shiftElementsToEnd(final List<T> source, final int count)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**//w ww . ja v a2s .c o m * returns a list of everything in source, with the first count units moved to the end */ public static <T> List<T> shiftElementsToEnd(final List<T> source, final int count) { final ArrayList<T> rVal = new ArrayList<>(source.size()); for (int i = count; i < source.size(); i++) { rVal.add(source.get(i)); } for (int i = 0; i < count; i++) { rVal.add(source.get(i)); } if (source.size() != rVal.size()) { throw new IllegalStateException("Didnt work for: " + count + " " + source + " : " + rVal); } return rVal; } }