没有明白么55555555。。
就是怎么把Hashtable里面的东西全部取出来啊

解决方案 »

  1.   

    it = hashtable.entrySet().iterator();
    while (it.hasNext()) {
     ...
    }
      

  2.   

    可以试试用elements()  方法取得一个 Enumeration 
    然后
    for (int i=0;i<=numbers.size() ;i++ )
               {
       Word word[i] = (Word ) Enumeration.nextElement();
                  
               }
      

  3.   

    it = hashtable.entrySet().iterator();
    while (it.hasNext()) {
     ...
    }这个方法好,学习  呵呵
      

  4.   

    楼上这位大哥,你的代码是不是只能提取那个值啊?可是我的那个key也要提取啊同时附给Word word[]啊这么办呢?
      

  5.   

    Set keySet() 
              Returns a Set view of the keys contained in this Hashtable. 
    Enumeration keys() 
              Returns an enumeration of the keys in this hashtable. 
    可是具体怎么用呢???
      

  6.   

    这样该可以了吧
    Word word[hashtable.size()];
    it = hashtable.entrySet().iterator();
    int i=0;
    while (it.hasNext()) {
       word[i]=new Word((String)(it.getKey()),((Integer)(it.getValue())).intValue());
    }
      

  7.   

    错了,改正下Word word[hashtable.size()];
    Set s= hashtable.entrySet();
    Iterator it=s.iterator();
    int i=0;
    while (it.hasNext()) {
       word[i]=new Word((String)(s.getKey()),((Integer)(s.getValue())).intValue());
    }
      

  8.   

    Word word[hashtable.size()];
    Map.entry s= hashtable.entrySet();
    Iterator it=s.iterator();
    int i=0;
    while (it.hasNext()) {
       word[i]=new Word((String)(s.getKey()),((Integer)(s.getValue())).intValue());
    }
    我都糊涂了,汗,现在该对了
      

  9.   

    有错啊
     1:cannot resolve symbol
    symbol  : method getKey ()
    location: interface java.util.Iterator
                                     word[i]=new Word((String)(it.getKey()),((Integer)(it.getValue())).intValue());
                                                                ^
    2: cannot resolve symbol
    symbol  : method getValue ()
    location: interface java.util.Iterator
                                     word[i]=new Word((String)(it.getKey()),((Intege
    r)(it.getValue())).intValue());     ^
      

  10.   

    cannot resolve symbolsymbol  : class entry
    location: interface java.util.Map
                            Map.entry s= numbers.entrySet();
                               ^
    还是有错555
      

  11.   

    Map.Entry
    大写的,我写急了,晕,。你不会自己查查API啊,晕
      

  12.   

    嘿嘿~~偶是新手哈不好意思哦
    可是还是有错
    incompatible types
    found   : java.util.Set
    required: java.util.Map.Entry
    Map.Entry s= numbers.entrySet();
                                 ^
    cannot resolve symbol
    symbol  : method iterator ()
    location: interface java.util.Map.Entry
    Iterator it=s.iterator();
                 ^
      

  13.   

    你用的是5.0版的吧,我查的是1.4.2的API
    Word word[hashtable.size()];
    Map.entry s= hashtable.entrySet();
    Iterator it=Hashtable.keySet().iterator();
    int i=0;
    while (it.hasNext()) {
       word[i]=new Word((String)(s.getKey()),((Integer)(s.getValue())).intValue());
    }