Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a public static method named inBoth that will take two ArrayList arguments. This method will return an ArrayList>. When called and passed two ArrayList
Write a public static method named inBoth that will take two ArrayList arguments. This method will return an ArrayList>. When called and passed two ArrayList arguments, this method will return an ArrayList containing all the elements that are in both argument ArrayList objects. There should be no duplicate values in the returned ArrayList, and the values the returned ArrayList must be in the same order as they are in the first argument ArrayList. Here are some examples: Example 1 Given: ArrayList list1 with these values {1,2,3,4,5} ArrayList list2 with these values {0,2,9,3} inBoth(myList) should return an ArrayList with these values {2,3} Example 2 Given: ArrayList> list1 with these values {3,1,2,3,5,1,0} ArrayList list2 with these values {0,2,9,3,5,5} inBoth(myList) should return an ArrayList> with these values {3,2,5,0} Example 3 Given: ArrayList list1 with these values {1,2,3,4,5} ArrayList list2 with these values {6,7,8} inBoth (mylist) should return an ArrayList> with these values \{\} Helpful Info
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started