Hashtable: keys() : Hashtable : java.util : Java by API examples (example source code) Organized by topic

Java by API
C++
PHP


Java by API  »  java.util   » [  Hashtable  ]   
 



Hashtable: keys()

/*
 * Output: 
key = apple; value = red
key = strawberry; value = red
 */

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

public class MainClass {

  public static void main(String args[]) {
    Hashtable hashtable = new Hashtable();
    hashtable.put("apple""red");
    hashtable.put("strawberry""red");

    Enumeration e = hashtable.keys();
    while(e.hasMoreElements()) {
      Object k = e.nextElement();
      Object v = hashtable.get(k);
      System.out.println("key = " + k + "; value = " + v);
    

  }
}
    
           
       
Related examples in the same category
1.  new Hashtable()
2.  new Hashtable < K, V > ()
3.  Hashtable: entrySet()
4.  Hashtable: iterator()
5.  Hashtable: keySet()
6.  Hashtable: put(K key, V value)
7.  Hashtable: get(E e)
























Home| Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.