Storing and Retrieving ArrayList values from hashmap

后端 未结 7 2529
感动是毒
感动是毒 2020-12-13 13:27

I have a hashmap of the following type

HashMap> map=new HashMap>();    
<         


        
7条回答
  •  隐瞒了意图╮
    2020-12-13 13:57

    You could try using MultiMap instead of HashMap

    Initialising it will require fewer lines of codes. Adding and retrieving the values will also make it shorter.

    Map> map = new HashMap>();
    

    would become:

    Multimap multiMap = ArrayListMultimap.create();
    

    You can check this link: http://java.dzone.com/articles/hashmap-%E2%80%93-single-key-and

提交回复
热议问题