EnumMap vs HashMap

  1. 1. EnumMap
  2. 2. HashMap
  3. Reference

1. EnumMap

  • Can only be used with enum type keys
  • It’s specialized implementation of Map Interface for use with enum type keys
  • Internally using arrays
  • stored in natural order
  • not possible for collision
  • much efficient compared with HashMap

2. HashMap

  • Extends AbstrctMap and implement Map interface
  • Internally using hashTable
  • Possible for collision

Reference

  1. https://www.geeksforgeeks.org/enummap-class-java-example/
  2. https://walkingtechie.blogspot.com/2017/03/difference-between-enummap-and-hashmap.html

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 stone2paul@gmail.com

文章标题:EnumMap vs HashMap

文章字数:74

本文作者:Leilei Chen

发布时间:2020-02-05, 01:10:34

最后更新:2020-02-05, 01:11:21

原始链接:https://www.llchen60.com/EnumMap-vs-HashMap/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏