Here you can find the source of rotate(List
public static <T> List<T> rotate(List<T> data, int n)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> List<T> rotate(List<T> data, int n) { List<T> result = new ArrayList<>(); int len = n % data.size() + ((n < 0) ? data.size() : 0); for (int i = 0; i < len; i++) result.add(data.get(data.size() + i - len)); for (int i = len; i < data.size(); i++) result.add(data.get(i - len)); return result; }/* ww w . j av a 2 s .co m*/ }