I have a query which returns List of Object[2]
. I would like to convert this into a MultiMap
which would contain Object[0]
as key and Object[1]
as value.
input list contains:
<id1, value1>
<id1, value2>
<id1, value3>
<id2, value1>
<id2, value2>
<id3, value2>
So when I do Collection coll = (Collection) multimap.get(id1);
col1
Should give --> value1,value2,value3
I can achive this looping through the list and putting it to the multimap, I would like to avoid that as my List is huge.
Thanks in advance!
for(Object obj[] : list ){
multimap.put(obj[0], obj[1]);
}
Assuming youre using apache multimap