-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_182_HashSet.java
41 lines (31 loc) · 1015 Bytes
/
a_182_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
39
40
41
import java.util.*;
public class a_182_HashSet {
public static void main(String[] args) {
HashSet<Integer> set = new HashSet<>() ;
set.add(100) ;
set.add(3) ;
set.add(5) ;
set.add(1) ;
set.add(2) ;
// set.add(null) ;
set.add(5) ;
// System.out.println(set);
// System.out.println(set.contains(3));
// System.out.println(set.contains(4));
// set.remove(1) ;
// System.out.println(set.remove(2));
// System.out.println(set.remove(1));
HashSet<String> cities = new HashSet<>() ;
cities.add("bhopal") ;
cities.add("singrouli") ;
cities.add("jabalpur") ;
cities.add("indore") ;
// Iterator it = cities.iterator() ;
// while(it.hasNext()){
// System.out.println(it.next());
// }
for(String city : cities){
System.out.println(city);
}
}
}