Online Java Compiler By
JavaTpoint.com
import java.util.HashSet; import java.util.Set; public interface JavaCollectionAddExample1 { public static void main(String[] args) { Set<Integer> set = new HashSet<>(); //add integer values in this collection set.add(34); set.add(12); set.add(45); System.out.print("The elements in Collection : "); System.out.println(set); } }
Output