You need to sign in to do that
Don't have an account?
Hitesh chaudhari
how to iterate over map
I am having a map<Custom Object , String> type .
I want to iterate over it so that in a single loop i will get output like
System.debug(key,value);
I want to iterate over it so that in a single loop i will get output like
System.debug(key,value);
You can iterate using KeySet() function:
for(Custom_Object__c objVar : map.keySet())
{
system.debug('Key = '+objVar+' Value = '+map.get(objVar));
}
Thanks,
Harsh
All Answers
Map< BMCServiceDesk__BMC_BaseElement__c , String> mymap= new Map< BMCServiceDesk__BMC_BaseElement__c , String>();
for (Id id : mymap.keySet())
{
System.debug(id);
System.debug(mymap.get(id)); // errror at this line
}
You can iterate using KeySet() function:
for(Custom_Object__c objVar : map.keySet())
{
system.debug('Key = '+objVar+' Value = '+map.get(objVar));
}
Thanks,
Harsh