Set keySet() Returns a Set view of the keys contained in this Hashtable. Enumeration keys() Returns an enumeration of the keys in this hashtable. 可是具体怎么用呢???
这样该可以了吧 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()); }
错了,改正下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()); }
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()); } 我都糊涂了,汗,现在该对了
有错啊 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()); ^
while (it.hasNext()) {
...
}
然后
for (int i=0;i<=numbers.size() ;i++ )
{
Word word[i] = (Word ) Enumeration.nextElement();
}
while (it.hasNext()) {
...
}这个方法好,学习 呵呵
Returns a Set view of the keys contained in this Hashtable.
Enumeration keys()
Returns an enumeration of the keys in this hashtable.
可是具体怎么用呢???
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());
}
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());
}
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());
}
我都糊涂了,汗,现在该对了
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()); ^
location: interface java.util.Map
Map.entry s= numbers.entrySet();
^
还是有错555
大写的,我写急了,晕,。你不会自己查查API啊,晕
可是还是有错
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();
^
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());
}