We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 82e9898 commit 6b2090eCopy full SHA for 6b2090e
Hashtable/Addition-using-hashtable.java
@@ -0,0 +1,32 @@
1
+import java.io.*;
2
+import java.util.*;
3
+
4
+class AddElementsToHashtable {
5
+ public static void main(String args[])
6
+ {
7
+ // No need to mention the
8
+ // Generic type twice
9
+ Hashtable<Integer, String> ht1 = new Hashtable<>();
10
11
+ // Initialization of a Hashtable
12
+ // using Generics
13
+ Hashtable<Integer, String> ht2
14
+ = new Hashtable<Integer, String>();
15
16
+ // Inserting the Elements
17
+ // using put() method
18
+ ht1.put(1, "Geeks");
19
+ ht1.put(2, "For");
20
+ ht1.put(3, "Geeks");
21
22
+ ht2.put(1, "Geeks");
23
+ ht2.put(2, "For");
24
+ ht2.put(3, "Geeks");
25
26
+ // Print mappings to the console
27
+ System.out.println("Mappings of ht1 : " + ht1);
28
+ System.out.println("Mappings of ht2 : " + ht2);
29
+ }
30
+}
31
32
0 commit comments