What is the output of the following code segments? Set<Integer> s = newTreeSet<I
ID: 3610426 • Letter: W
Question
What is the output of the following code segments? Set<Integer> s = newTreeSet<Integer>(); s.add(3); 4.System.out.println(s.add(7)); s.add(new Integer(9)); 5.System.out.println(s.add(new Integer(3))); for(int i : s) //newenhanced for loop 6. System.out.print(i); 4.____________ 5.____________ 6.____________ What is the output of the following code segments? Set<Integer> s = newTreeSet<Integer>(); s.add(3); 4.System.out.println(s.add(7)); s.add(new Integer(9)); 5.System.out.println(s.add(new Integer(3))); for(int i : s) //newenhanced for loop 6. System.out.print(i); 4.____________ 5.____________ 6.____________Explanation / Answer
Dear,
TreeSet - stores objects in a linear sequence, sorted by acomparison, with no duplicates