List Set Map - Collections in Apex (Salesforce)
List Set Map - Collections in Apex (Salesforce)
Data type
holding more than one data
is called
Collection
LIST
Ordered Collection, Can contain Duplicate
examples:
List<String> myListString = New List<String> {'text1', 'text2', 'text3'};
List<Integer> myListInteger = New List<Integer> {1, 5, 7, 200, 21};
List<Account> accountList = new List<Account>();
SET
UnOrdered Collection, Cannot contain Duplicate
example:
Set<String> mySetString = New Set<String> {'Banana', 'Apple', 'Mango'};
Syntax :
Map<IndexDataType, ValueDataType> mapName = New
Map<IndexDataType, ValueDataType> {1=>'element1', 2=>'element2'',
3=>'elem 3''};