Question: Arraylist Union and Intersection using iterator my union and intersection is weird... it is sorted arraylist but what i expected was for union:{1 2 3
Arraylist Union and Intersection using iterator

my union and intersection is weird... it is sorted arraylist but what i expected was for union:{1 2 3 4 5 6} and inetersection:{4 5} but it seems union just prints out everything iguess and the intersection printsout nothing
below is teh code
public static void getUnion(){ System.out.print("A Union B is:{"); Iterator
public static void getIntersection(){ ArrayList
Console union ava cation] C:\Pro am Files Java 1.8.0 Abin\iavaw.exe (Mar 21, 2017, 10:28:07 PM 1. Add element in A 2.Add element in B 3.Get union 4.Get Intersection S.Display current A and B 6. exit A Elements are: 1 2 3 4 5 B Elements are: 4 5 6 Please select the menu 1.Add element in A 2.Add element in B 3. Get union 4.Get Intersection 5.Display current A and B 6 exit A Union B is {1 2 3 4 54 5 61 Please select the menu: 1.Add element in A 2.Add element in B 3 Get union 4 Get Intersection s Display current A and B 6. exit A Intersect B is Please select the menu 1.Add element in A 2.Add element in B Get union 4. Get Intersection 5. Display current A and B 6 exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
