File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
CodingBlocks Training/Day23 Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ package Lecture23 ;
2+
3+ import java .util .HashMap ;
4+
5+ public class HashMapDemo {
6+
7+ public static void main (String [] args ) {
8+
9+ HashMap <String , Integer > map = new HashMap <String , Integer >();
10+
11+ map .put ("Nepal" , 100 );
12+ map .put ("USA" , 200 );
13+ map .put ("India" , 250 );
14+ map .put ("Denmark" , 300 );
15+
16+ System .out .println (map );
17+
18+ System .out .println (map .get ("Nepal" )); // 100
19+
20+ System .out .println (map .remove ("India" )); // 250
21+ System .out .println (map );
22+
23+ System .out .println (map .containsKey ("China" ));
24+ System .out .println (map .containsKey ("USA" ));
25+
26+ System .out .println (map .remove ("China" )); // null
27+ }
28+
29+ }
30+
31+ /* output:
32+ {USA=200, Denmark=300, Nepal=100, India=250}
33+ 100
34+ 250
35+ {USA=200, Denmark=300, Nepal=100}
36+ false
37+ true
38+ null
39+ */
You canβt perform that action at this time.
0 commit comments