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

Code Example 1

import java.util.HashSet;
public class HashSetObjectCloneMethodExample
{
   public static void main(String[] args)
   {
      HashSet<String> hs = new HashSet<String>();
      hs.add("Welcome");
      hs.add("hello");
      hs.add("world");
      hs.add("core");
      hs.add("java");
      System.out.println("HashSet before using clone() method: " + hs);
      // create new cloned HashSet
      HashSet<String> objClone = new HashSet<String>();
      // clone HashSet using clone() method
      objClone = (HashSet)hs.clone();
      // print new HashSet after cloning
      System.out.println("HashSet after using clone() method: " + objClone);
   }
}

Learn ReactJs, React Native from akashmittal.com