Check out example codes for "HashSet add(E e) method in java". It will help you in understanding the concepts better.

Code Example 1

import java.util.HashSet;
public class HashSetAddMethodExample
{
   public static void main(String[] args)
   {
      HashSet<String> hs = new HashSet<String>();
      // populating hash set
      hs.add("violet");
      hs.add("indigo");
      hs.add("blue");
      hs.add("green");
      hs.add("yellow");
      System.out.println("HashSet of colors: " + hs);
   }
}

Learn ReactJs, React Native from akashmittal.com