From c1973649496400330d97a112f80259f3f0f127e5 Mon Sep 17 00:00:00 2001 From: Aman5989 <95266619+Aman5989@users.noreply.github.com> Date: Tue, 4 Oct 2022 15:11:38 +0530 Subject: [PATCH] Create Addition-using-hashtable.java Here's a solution to opened issue create hashtable folder and a simple hashtable program --- Hashtable/Addition-using-hashtable.java | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Hashtable/Addition-using-hashtable.java diff --git a/Hashtable/Addition-using-hashtable.java b/Hashtable/Addition-using-hashtable.java new file mode 100644 index 00000000..e6aef62d --- /dev/null +++ b/Hashtable/Addition-using-hashtable.java @@ -0,0 +1,32 @@ +import java.io.*; +import java.util.*; + +class AddElementsToHashtable { + public static void main(String args[]) + { + // No need to mention the + // Generic type twice + Hashtable ht1 = new Hashtable<>(); + + // Initialization of a Hashtable + // using Generics + Hashtable ht2 + = new Hashtable(); + + // Inserting the Elements + // using put() method + ht1.put(1, "Geeks"); + ht1.put(2, "For"); + ht1.put(3, "Geeks"); + + ht2.put(1, "Geeks"); + ht2.put(2, "For"); + ht2.put(3, "Geeks"); + + // Print mappings to the console + System.out.println("Mappings of ht1 : " + ht1); + System.out.println("Mappings of ht2 : " + ht2); + } +} + +