Differentiate between List, Set and Map in Salesforce

List:
List is a ordered collection of values. It contains duplicate values. Each value is retrieved using the List Index.
Ex:
List<String> countryList = new List<String>();
countryList.add(‘India’);
countryList.add(‘USA’);
countryList.add(‘UK’);

Set:
Set is an unordered collection of values. It does not contains duplicate values.

Ex:
Country (Key) ‘United States’ ‘Japan’ ‘France’ ‘England’ ‘India’
Currency (Value) ‘Dollar’ ‘Yen’ ‘Euro’ ‘Pound’ ‘Rupee’

Map:
Map is a key value pair datatype.

Written by 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *

*