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
Abilash.SAbilash.S 

How to get all keys in Map

Q) Map<String,String> strMap = new Map<String,String>();
strMap.put('vehicle','car');
strMap.put('vehicle2','bike');  How to get all keys?
ANUTEJANUTEJ (Salesforce Developers) 
Hi Pavushetti,

>> https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_map.htm

As mentioned in the above documentation link there are certain methods you can perform on map class one such method is keySet() you can check this out in the above link.
 
Map<String, String> colorCodes = new Map<String, String>();
 
colorCodes.put('Red', 'FF0000');
colorCodes.put('Blue', '0000A0');
 
Set <String> colorSet = new Set<String>();
colorSet = colorCodes.keySet();

In case if this is a certification question I would request you to refrain from posting such questions going forward as this community is focused on Salesforce technical discussions where the forums and participants are geared toward programming troubleshooting and support.

Don't Post any kind of Certification questions on this Site.

Please close the thread by selected as Best Answer so that we can keep our community clean
​​​​​​
Regards,
Salesforce Support.