Online Java Compiler By
JavaTpoint.com
import java.util.*; public class HashSetSizeExample2 { public static void main(String[] args) { HashSet
hashSetObject = new HashSet <>(); hashSetObject.add(45); hashSetObject.add(-67); hashSetObject.add(98); int s = hashSetObject.size(); System.out.println("Size of HashSet is: "+s); } }
Output