Check out example codes for "how to push an element in hashset java". It will help you in understanding the concepts better.

Code Example 1

HashSet<Integer> set=new HashSet<>();
//adding a new element
set.add(10);

Learn ReactJs, React Native from akashmittal.com