1import java.util.TreeSet;
2public class TreeSetClearMethodExample
3{
4 public static void main(String[] args)
5 {
6 TreeSet<String> ts = new TreeSet<String>();
7 ts.add("grapes");
8 ts.add("apple");
9 ts.add("mango");
10 ts.add("banana");
11 ts.add("orange");
12 ts.add("pineapple");
13 System.out.println("TreeSet before using clear() method: " + ts);
14 // clear TreeSet using clear() method
15 ts.clear();
16 // print final TreeSet
17 System.out.println("TreeSet after using clear() method: " + ts);
18 }
19}