Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help filling in the code, I've highlighted the parts required: public class SetTester2 { public static void main(String[] args) { Set set1 = new
Need help filling in the code, I've highlighted the parts required:
public class SetTester2 { public static void main(String[] args) { Setset1 = new TreeSet () ; set1.add("A") ; set1.add("B") ; set1.add("C") ; set1.add("D") ; set1.add("F") ; set1.add("G") ; System.out.println("set1, the tree set: " + set1) ; Set set2 = new TreeSet () ; set2.add("B") ; set2.add("D") ; set2.add("E") ; set2.add("F") ; set2.add("G") ; System.out.println("set2, the tree set: " + set2) ; System.out.println("C is in set1: " + set1.contains("C")) ; System.out.println("C is in set2: " + set2.contains("C")) ; System.out.println("Removing C from set1: " +set1.remove("C")) ; System.out.println("Removing C from set2: " +set2.remove("C")) ; Set set3 = union(set1, set2) ; System.out.println("Union: " + set1 + " U " + set2 + " = " + set3) ; } /** A method that returns the union of two sets. @param x first set @param y second set @return the union set */ public static Set union(Set x, Set y) { //-----------Start below here. To do: approximate lines of code = 6 // 1. fill in the union method //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions. } }
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