//import the required library import java.util.*; //create a SortedSet object SortedSetIn this example, we create a SortedSet and a List, add some elements to the list, then use the addAll() method to add the elements to the SortedSet. The elements are automatically sorted in ascending order since we are using a TreeSet. The package library used in this example is java.util.set = new TreeSet (); //create a List object List list = new ArrayList (); //add elements to the list list.add(5); list.add(3); list.add(8); //use addAll() method to add elements to the set set.addAll(list); //print the sorted set System.out.println(set);