문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top