import com.google.common.collect.ImmutableSet; public class ImmutableSetExample { public static void main(String[] args) { // Static ImmutableSet ImmutableSetIn this example, we create three different ImmutableSet objects using immutable set API. The first set is created using static ImmutableSet method; the second set is created from an existing Set using copyOf() method, and the third set is created using the Builder pattern. The package com.google.common.collect belongs to the Google Guava library.fruitSet = ImmutableSet.of("Apple", "Banana", "Guava"); System.out.println("Static ImmutableSet: " + fruitSet); // Dynamic ImmutableSet using copyOf() Set vegSet = new HashSet<>(Arrays.asList("Tomato", "Onion", "Cabbage")); ImmutableSet vegetables = ImmutableSet.copyOf(vegSet); System.out.println("Dynamic ImmutableSet copyOf(): " + vegetables); // Using Builder pattern to create ImmutableSet ImmutableSet colourSet = ImmutableSet. builder() .add("Red", "Green", "Blue") .addAll(Arrays.asList("Yellow", "Purple", "White")) .build(); System.out.println("ImmutableSet using Builder: " + colourSet); } }