-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLearnHashset.java
More file actions
39 lines (28 loc) · 823 Bytes
/
LearnHashset.java
File metadata and controls
39 lines (28 loc) · 823 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
30
31
32
33
34
35
36
37
38
39
import java.util.*;
public class LearnHashset {
public static void main(String args[]){
Set<Integer> set = new HashSet<>();
set.add(10);
set.add(7);
set.add(25);
set.add(52);
set.add(44);
System.out.println(set);
set.remove(52);
System.out.println(set);
System.out.println(set.contains(25));
System.out.println(set.isEmpty());
set.add(10);
System.out.println(set);
set.remove(22);
System.out.println(set);
Set<Integer> set1 = new HashSet<>();
set1.add(101);
set1.add(150);
set1.add(122);
set.addAll(set1);
System.out.println(set);
set.removeAll(set1);
System.out.println(set);
}
}