Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.ArrayList; @SuppressWarnings(unchecked) public class TemplateLab7Bronze { public static void main(String[] args) { //Create two sample array lists with some common elements ArrayList a1 =
import java.util.ArrayList; @SuppressWarnings("unchecked") public class TemplateLab7Bronze { public static void main(String[] args) { //Create two sample array lists with some common elements ArrayList a1 = new ArrayList(); ArrayList a2 = new ArrayList(); int[] data1 = {45, 12, 98, 34, 6, 42}; int[] data2 = {6, 81, 36, 12, 77, 42}; for(int i=0; iBegin with the file TemplateLab7Bronze.java. Complete the method ArrayList extractDuplicates (ArrayList a1, ArrayList a2) which will look for elements that appear in both a1 and a2. When one is found, it should be removed from both a1 and a2. You can assume that neither list will contain duplicates. An ArrayList containing all of the elements that were removed should be returned as the result of the method The output printed by the main method should be al is [45, 12, 98, 34, 6, 421 a2 is [6, 81, 36, 12, 77, 421 removed elements: [42, 6, 12] al is now [45, 98, 34] a2 is now [81, 36, 77]
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