如何根据HashMap的value获得KEY? 请教 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 value可以重复,key不可以重复,我认为你不可能用value取道key 请教楼上遍历判断相等后如果取KEY呢?如下方法是遍历过程public static synchronized boolean deleteUserByName(String loginname) { Iterator it = hmUserList.keySet().iterator(); boolean bool = false; while (it.hasNext()) { Object obj = it.next(); if(hmUserList.get(obj).toString().startsWith(loginname + OperateCode.USER_CHAR_1)){ //hmUserList.remove(obj);???? bool = true; break; } } return bool; } 楼主这个好像有违Map的初衷啊 如果你hmUserList.get(obj)的value与你的value相同,那obj不就是你要的key值吗 解决问题,谢楼上www_sql(工业区)提醒 Java NIO 一直接收OP_ACCEPT的问题 问个傻瓜问题! 点浏览器的打印图标,只能打印表格里的数据,打印不出表格的边框,为什么啊?? 一个疑惑的基础问题? 容器的问题 复习中的新问题。请看!~ 强烈建议csdn推出eclipse板块~~~~~~~~ 数据库连接出错求助 关于导出数据的问题!!! 用applet播放音乐? 有关数据库连接的问题 怎样才能让一个应用程序的窗口总是最上层显示啊
如下方法是遍历过程
public static synchronized boolean deleteUserByName(String loginname) {
Iterator it = hmUserList.keySet().iterator();
boolean bool = false;
while (it.hasNext()) {
Object obj = it.next();
if(hmUserList.get(obj).toString().startsWith(loginname + OperateCode.USER_CHAR_1)){
//hmUserList.remove(obj);????
bool = true;
break;
}
}
return bool;
}