Tuesday, October 29, 2013

Looping Map in Apex Salesforce

How to loop map?Use values().It is quite useful if the map contain object where we need to get the object property.



Map<String,String> mapStr = new Map<String,String>();

mapStr.put('A','angsa');
mapStr.put('B','beruk');
mapStr.put('C','cicak');
system.debug('@mapStr ======'+mapStr);
for(String s:mapStr.values()){
    system.debug('@'+ s);
}
The output :
DEBUG|@mapStr ======{A=angsa, B=beruk, C=cicak}
DEBUG|@angsa
DEBUG|@beruk
DEBUG|@cicak

No comments:

Post a Comment