TreeSet last() method in java
import java.util.TreeSet;
public class TreeSetLastMethodExample
{
public static void main(String[] args)
{
TreeSet<Integer> ts = new TreeSet<Integer>();
ts.add(58);
ts.add(42);
ts.add(29);
ts.add(10);
// print last highest element
System.out.println("Last highest element is: " + ts.last());
}
}