List, Set and Map in Salesforce

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> temp = new List<String>();
temp.add(‘Newyork’);
temp.add(‘Miami’);

temp.add(‘Boston’);

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


Map:
    Map is a key value pair datatype.

Ex:

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

Cheers!!!

Leave a Reply