
public class Shifting{
    public static void main(String[] args){
        int[] a = new int[args.length];
        //fills array a with command line values
        for(int i = 0; i < a.length; i++){
            a[i] = Integer.parseInt(args[i]);
        }
        
        //prints the array
        for(int elt : a){
            System.out.print(elt + " ");
        }
        System.out.println();
        
        //shift array values one place to the right with wrap around
        // 1 2 3 4 5 will become 5 1 2 3 4
        int temp = a[a.length - 1];
        for (int i = a.length - 1; i > 0; i--){
            a[i] = a[i - 1];
        }
        a[0] = temp;
        //prints the array
        System.out.println ("array shifted right");
        for(int elt : a){
            System.out.print(elt + " ");
        }
        System.out.println();  

        //shifting values to the left
        temp = a[0];
        for(int i = 1; i < a.length; i++){
            a[i-1] = a[i];
        }
        a[a.length - 1] = temp;

        //prints the array
        System.out.println ("array shifted left");
        for(int elt : a){
            System.out.print(elt + " ");
        }
        System.out.println();  
    }
}