Here you can find the source of rotateArrayRange(int[] array, int from, int to, int n)
public static void rotateArrayRange(int[] array, int from, int to, int n)
//package com.java2s; import java.util.Arrays; public class Main { public static void rotateArrayRange(int[] array, int from, int to, int n) { rotateArrayRange(array, from, to, n, Arrays.copyOfRange(array, from, to)); }//from w ww.ja va 2 s .c o m public static void rotateArrayRange(int[] array, int from, int to, int n, int[] copyOfRange) { final int d = to - from; if (n < 0) n = to - from + n; for (int i = 0; i < d; ++i) array[from + i] = copyOfRange[(i + n) % d]; } public static <T> void rotateArrayRange(T[] array, int from, int to, int n) { rotateArrayRange(array, from, to, n, Arrays.copyOfRange(array, from, to)); } public static <T> void rotateArrayRange(T[] array, int from, int to, int n, T[] copyOfRange) { final int d = to - from; if (n < 0) n = to - from + n; for (int i = 0; i < d; ++i) array[from + i] = copyOfRange[(i + n) % d]; } }