Selasa, 21 April 2015

JAVA - How To Use Hashtable In Java NetBeans

Java - How To Display Elements And Keys From A Hashtable In Java

                                                                                                         


In this java Collection Tutorial we will see How To Show Elements From Hashtable
 In Java NetBeans .

Source Code:  

  

package javaapp;

import java.util.Enumeration;
import java.util.Hashtable;

public class Woirk {
    public static void main(String[] args){
        Hashtable ht = new Hashtable();
        
        //put data in a Hashtable
        ht.put(1, "JAVA");
        ht.put(10, "C#");
        ht.put(100, "PHP");
        ht.put(1000, "JAVASCRIPT");
        ht.put(10000, "VB.NET");
        
        Enumeration e = ht.elements();
        
        System.out.println("Display The Elements From The Hashtable");
        
        while(e.hasMoreElements())
            System.out.println(e.nextElement());
        
         System.out.println("Display The Keys From The Hashtable");
         
         Enumeration k = ht.keys();
         while(k.hasMoreElements())
             System.out.println(k.nextElement());
                 
    }
}

//////////////OUTPUT:

Display The Elements From The Hashtable
JAVASCRIPT
C#
VB.NET
PHP
JAVA
Display The Keys From The Hashtable
1000
10
10000
100

Bagikan

Jangan lewatkan

JAVA - How To Use Hashtable In Java NetBeans
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.