Java TreeSet.size()
Syntax
TreeSet.size() has the following syntax.
public int size()
Example
In the following code shows how to use TreeSet.size() method.
//from ww w . ja v a 2s . c om
import java.util.TreeSet;
public class Main {
public static void main(String[] args) {
TreeSet<Integer> treeadd = new TreeSet<Integer> ();
treeadd.add(1);
treeadd.add(13);
treeadd.add(17);
treeadd.add(2);
System.out.println("Size of the tree set is: "+treeadd.size());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »