TreeSet last() method in java
TreeSet last() method when elements are String types.
import java.util.TreeSet;
public class TreeSetLastMethodExample
{
public static void main(String[] args)
{
TreeSet<String> ts = new TreeSet<String>();
ts.add("grapes");
ts.add("banana");
ts.add("watermelon");
ts.add("apple");
// print last highest element
System.out.println("Last highest element is: " + ts.last());
}
}