shiftLeft

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

This problem should be completed without a loop. Take advantage of how a list shifts elements automatically when removing elements.

Given a list, shift all of the elements to the left 1. The left-most elements go to the end of the list (right side).


For example, shifting the list, [1 2 3], to the left produces [2 3 1] 

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.