Storing and Retrieving ArrayList values from hashmap

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

I have a hashmap of the following type

HashMap> map=new HashMap>();    
<         


        
7条回答
  •  情书的邮戳
    2020-12-13 13:46

    Fetch all at once =

    List list = null;
    
    if(map!= null) 
    { 
      list = new ArrayList(map.values()); 
    }
    

    For Storing =

    if(map!= null) 
    { 
      list = map.get(keyString); 
       if(list == null)
        {
             list = new ArrayList();
        }
      list.add(value);
      map.put(keyString,list);
    }
    

提交回复
热议问题