File tree 1 file changed +29
-0
lines changed
Lab Experiments/Experiment 9
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .util .*;
2
+
3
+ public class Exp9_6 {
4
+ public static void main (String [] args ) {
5
+
6
+
7
+ HashMap <Integer , String > hash_map = new HashMap <Integer , String >();
8
+
9
+
10
+ hash_map .put (10 , "Element at 10" );
11
+ hash_map .put (11 , "Element at 11" );
12
+ hash_map .put (19 , "Element at 19" );
13
+ hash_map .put (15 , "Element at 15" );
14
+ hash_map .put (3 , "Element at 3" );
15
+
16
+
17
+ System .out .println ("Mapped " + hash_map );
18
+
19
+ // Checking for the key_element '20'
20
+ System .out .println ("Element at position '2' : " + hash_map .containsKey (2 ));
21
+ System .out .println ("'Element at 10' Present : " + hash_map .containsValue ("Element at 10" ));
22
+ Set <Integer > keys = hash_map .keySet ();
23
+ System .out .println ("Key :" );
24
+ for (Integer key : keys ) {
25
+ System .out .println (key );
26
+ }
27
+ }
28
+
29
+ }
You can’t perform that action at this time.
0 commit comments