1.2K
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.