-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet_Hashset0.java
53 lines (23 loc) · 946 Bytes
/
Set_Hashset0.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
47
48
49
50
51
52
53
package com.mywork;
import java.util.HashSet;
import java.util.Set;
public class Set_Hashset0 {
public static void main(String[] args) {
Set<Integer> a = new HashSet<Integer>();
a.add(10);
a.add(20);
a.add(50);
a.add(20);
a.add(50);
a.add(70);//method --add
int size = a.size();//index of length
System.out.println("The value of index size = " + size); // (method ----size)
boolean contains = a.contains(90);
System.out.println("The given value in present or not in contains =" + contains);
// (it will check the value is present or not -- true or false)
boolean empty = a.isEmpty();
System.out.println("the vlue of index is empty or not:" + empty);
a.clear();
System.out.println(a);//will clear the index box
}
}