, ), )             n = (tab = resize()).length;         ) & hash]) == ; ; ++binCount) {                     )  &&             (first = tab[(n - ) & hash]) != , ), , ), , ), "nauyus"); Map<Cheese, String> map = new HashMap<>(); map.put(cheese, "something not important"); //一段被我忽略的代码 cheese.setCreator("tom"); System.out.println(map.get(cheese)); 

putHashMap 后,作为 key 的 cheese 对象再次被 set 了值,导致 hashCode 返回结果有了变更,put 奶酪后无法 get 到,奶酪再一次被动了

总结

总结一下踩坑经历,可以得出以下结论:

还有啊,没事还是少瞎改别人代码吧!

HashMap踩坑实录——谁动了我的奶酪-LMLPHP
04-27 04:29