Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsCheckedSetExample3 { public static void main(String[] args) { Set
set = new HashSet<>(); set = Collections.checkedSet(set, Integer.class); set.add(1500); set.add(1100); set.add(1800); System.out.println("Dynamic type safe view of Set is: "+set); Set set2 = set; set2.add("JavaTpoint"); System.out.println(set2); } }
Output