shiftRight

Objective: Write program code to create, traverse, and manipulate elements in 1D array or ArrayList objects.


This problem should be completed without a loop and should use remove.

Complete the shiftRight method that takes a list and shifts all the elements to the right by 1. 

The element at the rightmost side moves to the left-most side (first index). 

For example a call to shiftRighton a list [1 2 3] results in [3 1 2]
a call to rotate on a list [0 1 -5 2 3] results in [3 0 1 -5 2] 

remove(int index):
//given a list with elements 5, 3, 2, 1
list.remove(0); //removes element at index 0
list.remove(list.size()-1); //removes last element

By the way, remove also returns the element you removed!
int el = list.remove(0); //remove element at index 0 and store it in el

The following are methods of a list that can be used to manipulate the contained data. 

Type your solution        
Skills Practiced:
3.D
4.A
4.B
Copyright © StudyCS 2024 All rights reserved.