I have to rotate numbers an array.
Example:{5, 6, 7, 8} ==> {6, 7, 8, 5}{5, 6, 7, 8, 9, 10} ==> {6, 7, 8, 9, 10, 5}
This is what I have. It works for the most part to rotate the numbersbut I can't seem to rotate the first number to the left(the last location);It says the the variable I saved it in (a) may not be declared. Also Im not sure how I can make it loop so if I have more that 9 numbers in my array it will still work.
public void rotateLeft(int[] theArray){]int a;
for(int i = 0; i < theArray.length ; i++)theArray[0] = a
theArray[0] = theArray[1];
theArray[1] = theArray[2];
theArray[2] = theArray[3];
theArray[3] = theArray[4];
theArray[4] = theArray[5];
theArray[5] = theArray[6];
theArray[6] = theArray[7];
theArray[7] = theArray[8];
theArray[8] = theArray[9];
theArray[9] = a;
}