treeset clear 28 29 method in java

Solutions on MaxInterview for treeset clear 28 29 method in java by the best coders in the world

showing results for - "treeset clear 28 29 method in java"
Mathieu
30 Jan 2018
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}