Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

hash table implementation java

// Java program to demonstrate
// adding elements to Hashtable
  
import java.io.*;
import java.util.*;
  
class AddElementsToHashtable {
    public static void main(String args[])
    {
        // No need to mention the
        // Generic type twice
        Hashtable<Integer, String> ht1 = new Hashtable<>(4);
  
        // Initialization of a Hashtable
        // using Generics
        Hashtable<Integer, String> ht2
            = new Hashtable<Integer, String>(2);
  
        // Inserting the Elements
        // using put() method
        ht1.put(1, "one");
        ht1.put(2, "two");
        ht1.put(3, "three");
  
        ht2.put(4, "four");
        ht2.put(5, "five");
        ht2.put(6, "six");
  
        // Print mappings to the console
        System.out.println("Mappings of ht1 : " + ht1);
        System.out.println("Mappings of ht2 : " + ht2);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java time 
Java :: how to create a gui in java 
Java :: how to get string from resource id android 
Java :: how to add the last area of an array in java 
Java :: java date add hours 
Java :: how to use a combo box in java with if else 
Java :: java get filename without extension 
Java :: java extends 
Java :: import java.lang.Math.*; 
Java :: console java 
Java :: convert list of dto to map java 
Java :: mock ParameterizedTypeReference 
Java :: java_remove last char 
Java :: button change text java 
Java :: java program to sort an array 
Java :: phone number format java 
Java :: iterate list in java 
Java :: how to check if a person pressed a buuton in jframe 
Java :: java arraylist with double 
Java :: java instantiate a scanner 
Java :: local date to date java 
Java :: como crear un array list en java 
Java :: binary to decimal java 
Java :: android view set padding programmatically 
Java :: java remove item from list 
Java :: java set classpath 
Java :: thread implements runnable 
Java :: How to merge two sorted arrays into a single sorted bigger one? 
Java :: quicksort java 
Java :: mvn spring boot ends when closing vm 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =