Hashtable: entrySet() : 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: entrySet()

/*
{three=four, two=three, four=five, one=two}
4
three : four
two : three
four : five
one : two
three : four
two : three
four : five
one : two
 */

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MainClass {
  public static void main(String args[]) throws Exception {
    Hashtable hash = new Hashtable(89);
    hash.put("one""two");
    hash.put("two""three");
    hash.put("three""four");
    hash.put("four""five");
    System.out.println(hash);
    System.out.println(hash.size());
    Enumeration e = hash.keys();
    while (e.hasMoreElements()) {
      String key = (Stringe.nextElement();
      System.out.println(key + " : " + hash.get(key));
    }
    Set set = hash.entrySet();
    Iterator it = set.iterator();
    while (it.hasNext()) {
      Map.Entry entry = (Map.Entryit.next();
      System.out.println(entry.getKey() " : " + entry.getValue());
    }
  }
}


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
























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