-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapInterface4.java
More file actions
41 lines (33 loc) · 883 Bytes
/
Copy pathMapInterface4.java
File metadata and controls
41 lines (33 loc) · 883 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
34
35
36
37
38
39
40
41
package basicprograms;
import java.util.HashMap;
import java.util.Map;
public class MapInterface4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Map<String, Integer> m1 = new HashMap<String, Integer>();
m1.put("Mohan", 93);
m1.put("Sham", 82);
m1.put("HariPrasad", 90);
m1.put("Vinod", 87);
System.out.println(m1);
m1.remove("Vinod");
System.out.println(m1);
m1.remove("HariPrasad", 90);
System.out.println(m1);
m1.remove("Sham", 82);
System.out.println(m1);
m1.replace("Sham", 85);
System.out.println(m1);
m1.replace("Vinod", 87, 89);
System.out.println(m1);
m1.remove("Mohan");
System.out.println(m1);
Map<String, Integer> m2 = new HashMap<String, Integer>();
m1.put("Priya", 88);
m1.put("Ankita", 62);
m1.put("Twinkle", 70);
m1.put("Harry", 100);
m2.clear();
System.out.println(m2);
}
}