File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ import data .PersonModel ;
2
+
3
+ import java .util .HashMap ;
4
+ import java .util .Map ;
5
+
6
+ public class TheMap {
7
+
8
+ public static void main (String [] args ) {
9
+
10
+ Map <Integer , PersonModel > persons = new HashMap <>();
11
+
12
+ persons .put (1 , new PersonModel ("Survivor" , 15 ));
13
+ persons .put (2 , new PersonModel ("Eye of the Tiger" , 25 ));
14
+ persons .put (3 , new PersonModel ("Europe" , 17 ));
15
+
16
+ System .out .println (persons );
17
+ System .out .println (persons .keySet ());
18
+ System .out .println (persons .entrySet ());
19
+
20
+ System .out .println (persons .containsKey (5 ));
21
+ System .out .println (persons .values ());
22
+ System .out .println (persons .getOrDefault (5 , new PersonModel ("Dick" , 12 )));
23
+ System .out .println (persons .remove (3 ));
24
+ System .out .println (persons .size ());
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments