Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsUnmodifiableNavigableSetExample2 { public static void main(String[] args) { NavigableSet<String> set = new TreeSet<>(); Collections.addAll(set, "Google", "Facebook", "Instagram"); System.out.println("Initial Set: " + set); NavigableSet<String> set2 = Collections.unmodifiableNavigableSet(set); System.out.println("Unmodifiable Navigable Set: " + set2); //Modifying the original set set.add("Twitter"); System.out.println("Unmodifiable Navigable Set: " + set2); } }
Output