I have a list of the string contains duplicate values and I want to retain the duplicate value also in the Map and my code is below my list contains only 2 values while iterating in for loop I want all four values in Map with key and values and my code is below .please help. Thanks in advance
List<object> arr = new List<object>({COMPANYID=388,
CONTACTID=6362,ROLE_NAME=Architect},
{COMPANYID=388, CONTACTID=6663,ROLE_NAME=Developer},
{COMPANYID=399, CONTACTID=10358, ROLE_NAME=Engineer},
{COMPANYID=399, CONTACTID=10357, ROLE_NAME=Engineer});
Map<String,object> mp_StrObj = new Map<String,object>();
Map<string,object> FinalMap = new Map<string ,object>();
for(object obj :arr)
{
System.debug('Role: '+obj);
mp_StrObj = (Map<string,object>)obj;
FinalMap.put(string.valueof(mp_StrObj.get('COMPANYID')),mp_StrObj);
}
System.debug('FinalMap '+FinalMap);
when I print the final map it shows only 2 objects.but I want all the four in FinalMap Map