Collision resolution in Java HashMap

前端 未结 9 1970
半阙折子戏
半阙折子戏 2020-12-12 12:29

Java HashMap uses put method to insert the K/V pair in HashMap. Lets say I have used put method and now HashMap<

9条回答
  •  时光取名叫无心
    2020-12-12 13:19

    It isn't defined to do so. In order to achieve this functionality, you need to create a map that maps keys to lists of values:

    Map> myMap;
    

    Or, you could use the Multimap from google collections / guava libraries

提交回复
热议问题