for (Iterator iter = OnlineClient.htOnlineClients.keySet().iterator();
iter.hasNext(); ) {
int item = Integer.parseInt(iter.next().toString());
Online ol = (Online) OnlineClient.htOnlineClients.get(item);
if (ol.getCompanyID() == companyID) {
reOnline = ol;
break;
}
}
上面htOnlineClients的键是int类型的。如上正确,但如下,转换成String却出错。
for (Iterator iter = OnlineClient.htOnlineClients.keySet().iterator();
iter.hasNext(); ) {
String item = (String)iter.next();
Online ol = (Online) OnlineClient.htOnlineClients.get(item);
if (ol.getCompanyID() == companyID) {
reOnline = ol;
break;
}
}