/home/caleb/ASDV-Java/Assignments/lab16_arrays2_CalebFontenot/src/main/java/com/calebfontenot/lab16_arrays2_calebfontenot/ArrayShift2.java |
package com.calebfontenot.lab16_arrays2_calebfontenot;
@author
public class ArrayShift2 {
public static void main(String[] args)
{
int[] ar = {1, 2, 3, 4, 5};
int temp = ar[ar.length - 1];
for (int value : ar) {
System.out.print(value + " ");
}
System.out.println();
for (int i = (ar.length -1); i > 0 ; --i) {
ar[i] = ar[i -1];
}
ar[0] = temp;
for (int value : ar) {
System.out.print(value + " ");
}
}
}