Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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());
    }
}