import java.util.*;
public class demo1
{
public static void main(String[] args)
{
HashSet<String> hash_set = new HashSet<String>();
hash_set.add("C#");
hash_set.add("C++");
hash_set.add("Java");
hash_set.add("Python");
hash_set.add("Perl");
hash_set.add("Ruby");
System.out.println("Original Hash Set: " + hash_set);
HashSet <String> new_hash_set = new HashSet <String> ();
new_hash_set = (HashSet)hash_set.clone();
System.out.println("Cloned Hash Set: " + new_hash_set);
}
}
Java
Program to clone a hash set to another hash set.

Written by
View ProfileNikhil Juneja
Passionate software developer and technical contributor at TutorialsLink.
