TreeSet: remove(Object o) : TreeSet « java.util « Java by API






TreeSet: remove(Object o)

 
import java.util.TreeSet;

public class Main {
  public static void main(String[] args) {
    TreeSet<Integer> tSet = new TreeSet<Integer>();
    System.out.println("Size of TreeSet : " + tSet.size());

    tSet.add(new Integer("1"));
    tSet.add(new Integer("2"));
    tSet.add(new Integer("3"));

    System.out.println(tSet.size());

    // remove one element from TreeSet using remove method

    tSet.remove(new Integer("1"));
    System.out.println("Size of TreeSet after removal : " + tSet.size());
  }
}

   
  








Related examples in the same category

1.new TreeSet < E > ()
2.new TreeSet(Collection c)
3.new TreeSet < E > (Comparator < ? super E > c)
4.TreeSet: add(E o)
5.TreeSet: comparator()
6.TreeSet: headSet(T toElement)
7.TreeSet: first()
8.TreeSet: last()
9.TreeSet: subSet(T fromElement, T toElement)
10.TreeSet: tailSet(T fromElement)