Sunday 27 April 2014

TreeSet : size : Remove Element from the Set

int size()
Returns the number of elements in the set, If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
import java.util.*;
class TreeSetSize{
 public static void main(String args[]){
  TreeSet<Integer> mySet =new TreeSet<> ();
  
  /* Add elements to the set */
  mySet.add(1);
  mySet.add(-10);
  mySet.add(100);
  mySet.add(12);
  mySet.add(14);
  
  /* Display the set */
  System.out.println("Size Of the Set " +mySet.size());
 }
}

Output
Size Of the Set 5

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment