Get highest value stored in TreeSet in Java
Description
The following code shows how to get highest value stored in TreeSet.
Example
/*from w ww . j a v a 2 s .c om*/
import java.util.TreeSet;
public class Main {
public static void main(String[] args) {
TreeSet<String> tSet = new TreeSet<String>();
tSet.add("1");
tSet.add("5");
tSet.add("2");
tSet.add("3");
tSet.add("4");
System.out.println("Highest value Stored in Java TreeSet is : " + tSet.last());
}
}
The code above generates the following result.