Java Utililty Methods Array Rotate

List of utility methods to do Array Rotate

Description

The list of methods to do Array Rotate are organized into topic(s).

Method

ListfindAllPossibleRightRotations(int[][] matrix)
returns all 360 rotations in clock-wise in given matrix
List<int[][]> allPossibleRotations = new ArrayList<>();
for (int i = 0; i < 3; i++) {
    matrix = rotateClockWise(matrix);
    allPossibleRotations.add(matrix);
return allPossibleRotations;
Object[]rotateArray(Object[] array, int amt)
rotate Array
Object[] arr = Arrays.copyOf(array, array.length);
if (arr == null || amt < 0) {
    throw new IllegalArgumentException("Illegal argument!");
for (int i = 0; i < amt; i++) {
    for (int j = arr.length - 1; j > 0; j--) {
        Object temp = arr[j];
        arr[j] = arr[j - 1];
...
voidrotateArrayRange(int[] array, int from, int to, int n)
rotate Array Range
rotateArrayRange(array, from, to, n, Arrays.copyOfRange(array, from, to));