I am trying to take an int Array, and move all the integers to the right by one place, the last number in the array will go to array[0]. Like this:
public static void main(String[] OOOF)
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the integer of how long you want the array to be: ");
int length = in.nextInt();
int[] array = new int[length];
This segment fills the array with integer values inputted by the user:
for(int i = 0; i < length; i++)
{
System.out.println("Enter in an integer:");
array[i] = in.nextInt();
}
System.out.println(array);
This next segment swaps the end int and the first int:
int swap1 = array[0];
array[0] = array[length];
array[length] = swap1;
System.out.println(array);
This is where I am having trouble, I want to use some type of command that replaces that int at a specific point and then removes the original to be stored. Next... repeat that process in the for a loop until it is complete. I know that it is possible but haven't taken a computer science class in a couple of years...
int safe = myArr[length];
for(int j = 0; j < length; j++)
{
myArr[j+1] = myArr[j];
}
}
Please Help??