-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhashmap.java
34 lines (28 loc) · 831 Bytes
/
hashmap.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
package Hashing;
import java.util.*;
public class hashmap {
public static void main(String[] args) {
HashMap<String,Integer> h=new HashMap<>();
//insertion
h.put("India", 100);
h.put("China", 150);
h.put("Paki", 50);
System.out.println(h);
//get operation
int population=h.get("India");
System.out.println("Population of india is : "+population);
//contains key
System.out.println(h.containsKey("paki"));
System.out.println(h.containsKey("Paki"));//case sensitive
//remove
h.remove("China");
System.out.println(h);
//size
System.out.println(h.size());
System.out.println();
//clear
h.clear();
//is empty
System.out.println(h.isEmpty());
}
}