Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsUnmodifiableSortedSetExample1 { public static void main(String[] args) { SortedSet
set = new TreeSet
(); //Add values in the set set.add("Facebook"); set.add("Twitter"); set.add("Whatsapp"); set.add("Instagram"); //Create a Unmodifiable sorted set SortedSet
set2 = Collections.unmodifiableSortedSet(set); System.out.println("Unmodifiable Sorted set is :"+set2); set.add("Google"); System.out.println("Unmodifiable Sorted set after modify is:"+set2); } }
Output