Question: JAVA L3A1 Write a public static void method named shiftLeft which takes a single parameter of an ArrayList of String objects. The method should shift

JAVA L3A1

Write a public static void method named shiftLeft which takes a single parameter of an ArrayList of String objects. The method should shift every element of the parameter ArrayList one position to the left, and move the first element of the list into the last position.

For example, if the parameter list passed to the method initially prints as [dogs, monkeys, cats], this would become [monkey, cats, dogs] after the method is executed.

Write your shiftLeft method in the U7_L3_Activity_One class. Use the runner class to test your method but do not add a main method to your U7_L3_Activity_One.java file or your code will not be scored correctly.

Hint: think about which built in ArrayList methods can cause multiple elements to shift when they are called.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!