1import java.util.TreeSet;
2public class TreeSetRemoveMethodExample
3{
4 public static void main(String[] args)
5 {
6 TreeSet<String> ts = new TreeSet<String>();
7 ts.add("orange");
8 ts.add("green");
9 ts.add("blue");
10 ts.add("red");
11 ts.add("violet");
12 ts.add("yellow");
13 System.out.println("Given TreeSet: " + ts);
14 // remove elements using remove() method
15 ts.remove("blue");
16 ts.remove("violet");
17 ts.remove("red");
18 // print TreeSet after removal
19 System.out.println("New TreeSet: " + ts);
20 }
21}
22
23
24