What is the output of the following code segments? //ArrayList a contains the In
ID: 3610464 • Letter: W
Question
What is the output of the following code segments? //ArrayList a contains the Integers: 6 58 5 4 3 9 //ArrayList b contains the Integers: 5 47 Set<Integer> ta = newTreeSet<Integer>(a); Iterator<Integer> i =ta.iterator(); while(i.hasNext()) 12. System.out.print(i.next() +" "); System.out.println(); Set<Integer> ha = newHashSet<Integer>(a); i = ha.iterator(); while(i.hasNext()); 13. System.out.print(i.next()+ " "); System.out.println(); 14.System.out.println(ta.removeAll(b)); 15.System.out.println(ta); 12.____________ 13.____________ 14.____________ 15.____________ What is the output of the following code segments? //ArrayList a contains the Integers: 6 58 5 4 3 9 //ArrayList b contains the Integers: 5 47 //ArrayList b contains the Integers: 5 47 Set<Integer> ta = newTreeSet<Integer>(a); Iterator<Integer> i =ta.iterator(); while(i.hasNext()) 12. System.out.print(i.next() +" "); System.out.println(); Set<Integer> ha = newHashSet<Integer>(a); i = ha.iterator(); while(i.hasNext()); 13. System.out.print(i.next()+ " "); System.out.println(); 14.System.out.println(ta.removeAll(b)); 15.System.out.println(ta); 12.____________ 13.____________ 14.____________ 15.____________ 15.____________Explanation / Answer
12. 3 4 5 6 8 9 ,because “Treeset” allows the elements to be retrievedin a particular order.
13. 9 3 4 5 8 6
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.