-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSet_Demo.java
46 lines (38 loc) · 1.03 KB
/
Set_Demo.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
40
41
42
43
44
45
46
//public class Set_Demo {
//}
import java.util.*;
public class Set_Demo {
public static void main(String[] args) {
// TODO Auto-generated method stub
HashSet<Integer> set = new HashSet<>();
set.add(-90);
set.add(9);
set.add(77);
set.add(56);
set.add(88);
set.add(56);
// set.add(null);
System.out.println(set);
// System.out.println(set.remove(-90));
// System.out.println(set);
// System.out.println(set.contains(88));
TreeSet<Integer> set1 = new TreeSet<>();
set1.add(-90);
set1.add(9);
set1.add(77);
set1.add(56);
set1.add(88);
set1.add(56);
// set1.add(null);
System.out.println(set1);
LinkedHashSet<Integer> set2 = new LinkedHashSet<>();
set2.add(-90);
set2.add(9);
set2.add(77);
set2.add(56);
set2.add(88);
set2.add(56);
//set2.add(null);
System.out.println(set2);
}
}