HashSet size() Method in Java

The size() method of HashSet returns the number of elements available in the HashSet. Syntax Parameters It does not take any parameter Return Value It returns the number of elements in the HashSet Program 1 Output Set elements: [50, 20, 40, 10, 30] Number of elements in set: 5