Java

Program to empty an hash set.

Program to empty an hash set.
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);
  hash_set.removeAll(hash_set);
  System.out.println("Hash Set after removing the elements "+hash_set);   
  }
}
Nikhil Juneja

Passionate software developer and technical contributor at TutorialsLink.