1import java.util.TreeSet;
2public class TreeSetSizeMethodExample
3{
4 public static void main(String[] args)
5 {
6 TreeSet<String> ts = new TreeSet<String>();
7 ts.add("watermelon");
8 ts.add("apple");
9 ts.add("banana");
10 ts.add("grapes");
11 ts.add("mango");
12 ts.add("orange");
13 System.out.println("Given TreeSet: " + ts);
14 // print size of TreeSet
15 System.out.println("size of TreeSet is: " + ts.size());
16 }
17}
18
19
20