标题: [已解决]debug奇闻怪事HashMap之containsValue();
时间: 2022-03-23发布,2022-03-23修改
提问:为什么用containsValue();判断HashMap是否包含字符串“憨憨”,返回值却是true???
public static void main(String[] args) {
HashMap hm =new HashMap();
// hm.put(1000,"张飞");
hm.put(1001,"刘备");
// hm.put(1002,"关羽");
boolean res2 = hm.containsValue("憨憨"); // true
System.out.println(res2);
}
奇闻怪事求助:
为了缩小范围,判断条件不变:“憨憨”,
一次只放入一条key-value键值对,结果如下:
张飞:憨憨 // false
刘备:憨憨 // true
关羽:憨憨 // true
『回复列表(7|隐藏机器人聊天)』