import java.util.Set;
import java.util.TreeSet;
public class RemoveAll {
public static void main(String[] args) {
Set<String> ts = new TreeSet<String>();
ts.add("mumbai");
ts.add("delhi");
ts.add("kolkata");
ts.add("chandigarh");
ts.add("dehradun");
// print treeset
System.out.println(" Before Clear TreeSet is ="+ts);
/*
* Removes all of the elements from set
*/
ts.clear();
System.out.println(" After Clear Treeset is = "+ts);
}
}
Output:
Before Clear TreeSet is =[chandigarh, dehradun, delhi, kolkata, mumbai]
After Clear Treeset is = []
import java.util.TreeSet;
public class RemoveAll {
public static void main(String[] args) {
Set<String> ts = new TreeSet<String>();
ts.add("mumbai");
ts.add("delhi");
ts.add("kolkata");
ts.add("chandigarh");
ts.add("dehradun");
// print treeset
System.out.println(" Before Clear TreeSet is ="+ts);
/*
* Removes all of the elements from set
*/
ts.clear();
System.out.println(" After Clear Treeset is = "+ts);
}
}
Output:
Before Clear TreeSet is =[chandigarh, dehradun, delhi, kolkata, mumbai]
After Clear Treeset is = []
No comments:
Post a Comment