function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amateur1amateur1 

how to pass two values for a key in map without overwriting

hi i have two queries for two non relational objects . they have same fields date for both 

 

now in my map i want to put a key when retrieved should get the records from both the objects that are having the same date

Navatar_DbSupNavatar_DbSup

Hi,

 

It is not possible in map because 1 key contains multiple unique values.

 

If you want to store duplicate values then you can use List with the map.

 

For example

 

Map<integer, list<string>>  ss=new Map< integer ,list<string>>  ();

List<string> s1=new list<string>(){‘a’,’b’,’c’,’a’,’b’};

ss.put(1,s1);

 

for more detail follow below link:

http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.