Get lowest and highest value stored in Java TreeSet
import java.util.TreeSet; public class Main { public static void main(String[] args) { TreeSet<String> tSet = new TreeSet<String>(); tSet.add("1"); tSet.add("2"); tSet.add("3"); tSet.add("4"); tSet.add("5"); System.out.println("Lowest value Stored in Java TreeSet is : " + tSet.first()); System.out.println("Highest value Stored in Java TreeSet is : " + tSet.last()); } }