Notes
Arrays:
String [] myArray= new List<String>();
Lists:
List<string> myList = new List<string>();
Sets:
Set<string> mySet = new Set<string>();
Maps:
Map<string, string> myMap = new Map<string, string>();
|
Lists |
Sets |
Maps |
add() |
|
|
|
put() |
|
|
|
remove() |
|
|
|
removeAll() |
|
|
|
size() |
|
|
|
get() |
|
|
|
getSObjectType() |
|
|
|
clear() |
|
|
|
clone() |
|
|
|
addAll() |
|
|
|
contains() |
|
|
|
containsKey() |
|
|
|
containsAll() |
|
|
|
deepClone() |
|
|
|
equals() |
|
|
|
indexOf() |
|
|
|
isEmpty() |
|
|
|
sort() |
|
|
|
set() |
|
|
|
toString() |
|
|
|
hasCode() |
|
|
|
Convert a List to a Set:
List<String> a = new List<String>{'A','B','C'};
Set<String> b = new Set<String>(a);
System.debug('List: '+a);
System.debug('Set: ' +b);
Convert a Set to a List:
Set<String> a = new Set<String>{'A','B','C','A','B','C'};
List<String> b = new List<String>(a);
System.debug('Set: '+a);
System.debug('List: ' +b);
Note: Duplicate elements of the set will not be available in the List.