-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM48_HashSet.java
38 lines (31 loc) · 976 Bytes
/
M48_HashSet.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
import java.util.Set;
import java.util.HashSet;
class M48_HashSet{
public static void main(String [] args){
Set<Integer> num = new HashSet<Integer>();
num.add(54);
num.add(82);
num.add(10);
num.add(29);
num.add(82);
System.out.println(num);
HashSet<String> names = new HashSet<String>();
names.add("Mohammad");
names.add("Musharruf");
names.add("Nawaz");
for(String name : names){
System.out.println(name);
}
}
}
/*
Note :
Set will not give the values in sorted format.
Set will not contain duplicate elements.
Set does not support index value.
This class implements the Set interface.it does not
guarantee that the order will remain constant over time.
This class permits the null element.
This class offers constant time performance for the
basic operations (add, remove, contains and size).
*/