Create a class called MyArrayList and implement the methods below, in addition to a main method to test your code. Focus on the special cases. 1. Write a method intersect that accepts two sorted array...


Create a class called MyArrayList and implement the methods below, in addition to a main method to test
your code. Focus on the special cases.
1. Write a method intersect that 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. 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]
Write a main method to test your code. Focus on the special cases
2. Write a method reverse that reverses the order of the elements in an ArrayList of strings.
3. Write a method capitalizePlurals that accepts an ArrayList of strings and replaces every word ending
with an "s" with its uppercased version.
4. Write a method removePlurals that accepts an ArrayList of strings and removes every word in the list
ending with an "s", case-insensitively.
5. Write a method called scaleByK that takes an ArrayList of integers as a parameter and replaces every
integer of value K with K copies of itself. For example, if the list stores the values (4, 1 , 2, 0 ,3) before
the method is called, it should store the values (4, 4, 4, 4, 1, 2, 2, 3, 3, 3) after the method finishes
executing. Zeroes and negative numbers should be removed from the list by this method



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here