Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program using JAVA that prints out the lists after the following methods are called. Medthod removeOddLength: takes an ArrayList of strings as a

Write a program using JAVA that prints out the lists after the following methods are called.

Medthod removeOddLength: takes an ArrayList of strings as a parameter and removes all of the strings of odd length from the list.

Method swapPairs: Switches the order of values in an ArrayList of strings in a pairwise fashion. Your method should switch the order of the first two values, then the next two, then the next two and so on. If the number of values in the list is odd, the method should not move the final element. For example, if the list stores [madam, I, am, your, adam] your method should change this lists content to [I, madam, your, am, adam]

Method intersect: accepts two sorted array lists of integers as parameters and returns a new list that contains only the elements that are found in both lists. For example, if lists named list1 and list2 initially store:

[1, 4, 8, 9, 11, 15, 17, 28, 41, 59]

[4, 7, 11, 17, 19, 20, 23, 28, 37, 59, 81]

Then the call of intersect(list1, list2) returns the list:

[4, 11, 17, 28, 59]

Print the list that is returned by this method.

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions