Java tutorial
import java.util.Collections; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; public class Main { public static void main(String[] s) { SortedSet<String> set = new TreeSet<String>(); set.add("Welcome"); set.add("to"); set.add("java2s.com"); System.out.println("Initial set value: " + set); // create unmodifiable sorted set Set<String> unmodsortset = Collections.unmodifiableSortedSet(set); // try to modify the sorted set unmodsortset.add("Hello"); } }