Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java HashTable

//Java Hashtable
//--------------
  
import java.io.*;
import java.util.*;
  
class AddElementsToHashtable {
    public static void main(String args[])
    {
       
        Hashtable<Integer, String> h1 = new Hashtable<>();
  
        // Initialization of a Hashtable using Generics
        Hashtable<Integer, String> h2 = new Hashtable<Integer, String>();
  
        // Inserting the Elements using put() method
        //                              ------------
        ht1.put(1, "Chris");
        ht1.put(2, "Tony");
        ht1.put(3, "Peter");
        ht2.put(4, "Steven");
  
        // Print mappings to the console (Output)
        System.out.println("Mappings of Hash Table 1 : " + h1);
        System.out.println("Mappings of Hash Table 2 : " + h2);
    }
}
Source by www.javatpoint.com #
 
PREVIOUS NEXT
Tagged: #Java #HashTable
ADD COMMENT
Topic
Name
7+2 =