Consider the following program:
import java.util.*; public class Main { public static void main(String []args) { Set<Integer> set = new TreeSet<Integer>(); set.add(5);/*ww w.j av a2 s . com*/ set.add(10); set.add(3); set.add(5); System.out.println(set); } }
What will be the output of this program?
c)
TreeSet is a sorted set; hence, all the inserted items are sorted in ascending order.
Also, since TreeSet is a Set, it will remove any duplicate item inserted.