Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsUnmodifiableCollectionExample1 { public static void main(String[] args) { Collection
c = new ArrayList<>(); Collections.addAll(c, "Google", "Mozila FireFox", "Yahoo"); Collection
c2 = Collections.unmodifiableCollection(c); System.out.println("Unmodifiable Collection: " + c2); c.add("Safari"); System.out.println("Unmodifiable Collection after adding element to the original one:"); System.out.println(c2); } }
Output