HashMap :不允许键重复,IdentityHashMap:允许键重复

HashMap 不允许键重复,如果键重复了,它会保留最后一条
如果遇到键一样,但是值不一样。想要允许键重复的,用IdentityHashMap

两个map创建方式如下:
Map<Long, StudentVo> studentMap = new HashMap<>(studentList.size()); Map<Long, StudentVo> studentMap = new IdentityHashMap<>(studentList.size());

猜你喜欢

转载自blog.csdn.net/weixin_43228497/article/details/115165227