So the goal is to rotate the elements in an array right a times. As an example; if a==2, then array = {0,1,2,3,4} would become
a
a==2
array = {0,1,2,3,4}
Another way is copying with System.arraycopy.
int[] temp = new int[array.length]; System.arraycopy(array, 0, temp, a, array.length - a); System.arraycopy(array, array.length-a, temp, 0, a);