Click here to watch in Youtube :
https://www.youtube.com/watch?v=wb5gRtlKcPA&list=UUhwKlOVR041tngjerWxVccw
TreeSetExample.java
Output
https://www.youtube.com/watch?v=wb5gRtlKcPA&list=UUhwKlOVR041tngjerWxVccw
TreeSetExample.java
import java.util.TreeSet; /* * Example of clear() method. */ public class TreeSetExample { public static void main( String[] args ) { TreeSet<Integer> treeSet = new TreeSet<Integer>(); treeSet.add(10); treeSet.add(50); treeSet.add(40); treeSet.add(20); treeSet.add(30); System.out.println("treeSet : " + treeSet + "\n"); /* * Removes all of the elements from this set. The set will be empty * after this call returns. */ treeSet.clear(); System.out.println("treeSet : " + treeSet + "\n"); } }
treeSet : [10, 20, 30, 40, 50] treeSet : []
https://sites.google.com/site/javaee4321/java-collections/TreeSetDemoClear.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment