package devmanuals.com; import java.util.*; public class FirstAndLastValueSortedSet { public static void main(String args[]) { SortedSet Sset = new TreeSet(); Sset.add("Gyan"); Sset.add("Ankit"); Sset.add("Arun"); Sset.add("Anand"); Sset.add("Ram"); System.out.println("The SortedSet entries is as follows : " + Sset); System.out.println("The first element of the set is : " + Sset.first()); System.out.println("The last element of the set is : " + Sset.last()); } }