This method is used to rotate all the elements in arr one position to the right. This rotation will result in arr[0] moving to arr[1] and arr[1] moving to arr[2] ... etc. Finally, arr[arr.length-1] moves to arr[0]. code example
Example: array rotation program in java
static void rotLeft(int[] a, int d)
{
int [] n = new int[a.length];
for(int i = 0; i < a.length; i++)
{
int newlocation = (i+(a.length - d))% a.length;
n[newlocation] = a[i];
}
for(int i = 0; i < a.length; i++)
{
System.out.print(n[i]+ " ");
}
}