Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS RUNNER CODE: import java.util.Scanner; import java.util.ArrayList; public class runner_U7_L3_Activity_One{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); ArrayList words = new

image text in transcribed

THIS IS RUNNER CODE: import java.util.Scanner; import java.util.ArrayList;

public class runner_U7_L3_Activity_One{

public static void main(String[] args){ Scanner scan = new Scanner(System.in); ArrayList words = new ArrayList(); System.out.println("Please enter words, enter STOP to stop the loop."); String input = scan.nextLine(); while(!input.equals("STOP")){ words.add(input); input = scan.nextLine(); } U7_L3_Activity_One.shiftRight(words); System.out.println(words); } }

Instructions Write a public static void method named shiftright 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 right, and move the last element of the list into the first position. For example, if the parameter list passed to the method initially prints as [I, am, here, this would become there, i, ami after the method is executed. Write your shiftRight method in the U7_13_Activity_One class. Use the runner class to test your method but do not add a main method to your U7_LB_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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

In what way does an operator benefit through machine coupling?

Answered: 1 week ago

Question

3. Understand the nature and importance of inventories

Answered: 1 week ago