java.util.Enumeration enum = hasht.keys();
   while(enum.hasMoreElements()){
        …………
        your Code
        …………

解决方案 »

  1.   

    补充:
       在while循环里
       用enum.nextElement();取出hashtable的key
       在用hasht.get(key),取出和key对应的值
      

  2.   

    用enum.nextElement();取出hashtable的key比如在hashtable里有  "1"---"A"、"2"---"B"
    那么:
        在while里
        String  num=enum.nextElement();
        此时 num为1或者num为2
      

  3.   

    for (Enumeration ee = hasht.elements(),bb = hasht.keys(); ee.hasMoreElements();) 
    {
        System.out.println(bb.nextElement()+": "+(强制类型转换)ee.nextElement());
    }
      

  4.   

    java.util.Enumeration enum = hasht.keys();
    while(enum.hasMoreElements())
    {
    String tempId = null;
    String tempName = null;

    tempId = (String)enum.nextElement();
    tempName = (String)hasht.get(tempWsId);
             }这样对么?怎么出错呀!
      

  5.   

    你的hashtable存的是什么值?贴出内容来
      

  6.   

    从数据库取得值, tempId = new Integer(rs.getInt("id"));
    tempDes = rs.getString("des");

    hasht.put(tempId,tempDes);
      

  7.   

    //有一个是int。
    java.util.Enumeration enum = hasht.keys();
    while(enum.hasMoreElements())
    {
    int tempId = 0;
    String tempName = null;

    tempId = (String)enum.nextElement();
    tempName = (String)hasht.get(new Integer(tempId));
             }
      

  8.   

    sorry:
    tempId = (String)enum.nextElement();
    --->
    tempId = ((Integer)enum.nextElement()).intValue();