好吧,所以我目前正在寻找一种搜索方法,搜索的术语是通过数据库运行的,并且匹配的产品被添加到一个带有2个Integer字段的hashMap中。迭代通过HashMap
然后HashMap中作出后,将被显示的项目,但我遇到麻烦HashMap中打印出来的细节
这里是我的代码
public HashMap<Integer, Integer> bankSearch = new HashMap<Integer, Integer>();
和使用
Iterator it = bankSearch.entrySet().iterator();
while (it.hasNext()) {
HashMap.Entry pairs = (HashMap.Entry)it.next();
System.out.println(pairs.getKey() + " = " + pairs.getValue());
if (bankItemsN[i] > 254) {
outStream.writeByte(255);
outStream.writeDWord_v2(pairs.getValue());
} else {
outStream.writeByte(pairs.getValue()); // amount
}
if (bankItemsN[i] < 1) {
bankItems[i] = 0;
}
outStream.writeWordBigEndianA(pairs.getKey()); // itemID
}
电流误差
.\src\client.java:75: cannot find symbol
symbol : class Iterator
location: class client
Iterator it = bankSearch.entrySet().iterator();
^
.\src\client.java:77: java.util.HashMap.Entry is not public in java.util.HashMap
; cannot be accessed from outside package
HashMap.Entry pairs = (HashMap.Entry)it.next();
^
.\src\client.java:77: java.util.HashMap.Entry is not public in java.util.HashMap
; cannot be accessed from outside package
HashMap.Entry pairs = (HashMap.Entry)it.next();
^
3 errors
Press any key to continue . . .
什么Java编译器是您使用?另外,是否有一个特别的原因,你不使用Java泛型? – templatetypedef