Java TreeSet.first()
Syntax
TreeSet.first() has the following syntax.
public E first()
Example
In the following code shows how to use TreeSet.first() method.
/*ww w.ja v a2 s.c o m*/
import java.util.TreeSet;
public class Main {
public static void main(String[] args) {
TreeSet <Integer> treeadd = new TreeSet<Integer> ();
treeadd.add(12);
treeadd.add(11);
treeadd.add(16);
treeadd.add(15);
// getting the first lowset element
System.out.println("First lowest element: "+treeadd.first());
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »