Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to perform Map of get vs containskey in apex efficient check?

Asked by Dipesh Bhardwaj May 9, 2023 1.8K views 1 answer
Share

About this question

I have map Map sampleMap ;

I have little confusion on the two map methods. i got a review saying that to use containsKey method rather than get method. But I am thinking in a way that the get will also check if the value is null or not ?

if(sampleMap.get('XXX') != null ) { //do stuff } if(sampleMap.containsKey('XXX')) { //do stuff }

Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.