-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathP_HashSet.java
More file actions
29 lines (26 loc) · 745 Bytes
/
P_HashSet.java
File metadata and controls
29 lines (26 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package SummerTrainingGFG.Hashing;
import java.util.HashSet;
import java.util.Iterator;
/**
* @author Vishal Singh */
public class P_HashSet {
public static void main(String[] args) {
HashSet<String> h = new HashSet<String>();
h.add("Hello");
h.add("I am");
h.add("Hashing");
System.out.println(h);
System.out.println(h.contains("Hello"));
Iterator<String> i = h.iterator();
while (i.hasNext()){
System.out.print(i.next()+" ");
}
h.remove("I am");
System.out.println("\nSize: "+h.size());
for (String s:
h) {
System.out.println(s);
}
System.out.println("Is empty: "+h.isEmpty());
}
}