Online Java Compiler By
JavaTpoint.com
import java.util.*; public class HashSetSizeExample1 { public static void main(String[] args) { HashSet
set=new HashSet
(); set.add("Ravi"); set.add("Vijay"); set.add("Mohan"); set.add("Ajay"); //Print the HashSet System.out.println("HashSet: " + set); //Displaying the size of the HashSet System.out.println("The size of the set is: " + set.size()); } }
Output