-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashMapSample.java
More file actions
33 lines (25 loc) · 885 Bytes
/
HashMapSample.java
File metadata and controls
33 lines (25 loc) · 885 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
import java.util.HashMap;
public class HashMapSample {
public static void main(String[] args) {
HashMap<String, Integer> data = new HashMap<String, Integer>();
data.put("A", 10);
data.put("B", 15);
data.put("C", 20);
// Get using for add a data
System.out.println(data.get("A"));
System.out.println(data.get("B"));
System.out.println(data.get("C"));
// Remove using for delete dat
data.remove("A");
System.out.println(data);
// containsKey Using for check the Key is there ot not
if(data.containsKey("F")){
System.out.println("This item is there");
}else{
System.out.println("This item is no there");
}
// Clear Using For clearing full data in hashmap
data.clear();
System.out.println(data);
}
}