1import java.util.HashSet;
2public class HashSetClearMethodExample
3{
4 public static void main(String[] args)
5 {
6 HashSet<String> hs = new HashSet<String>();
7 hs.add("Welcome");
8 hs.add("hello");
9 hs.add("world");
10 hs.add("core");
11 hs.add("java");
12 System.out.println("HashSet before using clear() method: " + hs);
13 // HashSet clear() method
14 hs.clear();
15 System.out.println("HashSet after using clear() method: " + hs);
16 }
17}