-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashing.java
39 lines (34 loc) · 1.01 KB
/
hashing.java
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
30
31
32
33
34
35
36
37
38
39
import java.util.HashSet;
// import java.util.Iterator;
public class hashing {
public static void main(String[] args) {
//Creation
HashSet<Integer> set = new HashSet<>();
//Insertion
set.add(1);
set.add(2);
set.add(3);
set.add(1);
//Search - contains
// if(set.contains(1)){
// System.out.println("Set contains 1");
// }
// if(!(set.contains(6))){
// System.out.println("Does not contain");
// }
// //Delete
// set.remove(1);
// if(!(set.contains(1))){
// System.out.println("does not contain 1");
// }
// System.out.println("Size of set is : " + set.size());
//Print all elements
// System.out.println(set);
//Iterator
// Iterator it = set.iterator();
// //hasNext; next
// while(it.hasNext()){
// System.out.println(it.next());
// }
}
}