Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsUnmodifiableCollectionExample3 { public static void main(String[] args) { Collection
coll = new ArrayList<>(); coll.add(10); coll.add(20); coll.add(30); coll.add(40); Collection
coll2 = Collections.unmodifiableCollection(coll); System.out.println("Unmodifiable collection: " + coll2); coll.add(50); System.out.print("Unmodifiable collection after adding (50): "+coll); }
Output