Tag Archives: collections

Map in Salesforce

Map It is key value pair. Key must be primitive data type and value may be primitive data types/Reference data type. Primitive data type are integer,decimal,string,id,Boolean,data… Only one key value is allowed to be null. Syntax Map<key,value> variablename = new map<key,value>(); Data is storing according to keys dictionary order. keys are case sensitive Methods Put(key,value);… Read More »

Set in Salesforce

Set It doesn’t allow duplicates. It maintains dictionary order. Set maintains hash code mechanism. It allows only one null value. Syntax set<Datatype> variable name = new set<Datatype>(); Methods Add(Element); addAll(list/set s); contains(Element); containsAll(set/list s); size(); clear(); remove(Element); Share this…WhatsappFacebookEmail

List in Salesforce

List It allows Duplicate values . It maintains insertion order. List maintains index based. It allows multiple null values. Syntax List<Datatype> variable name = new List<Datatype>(); Examples List<integer> a = new List<integer>(); List<Account> b = new List<Account>(); List<integer> ages;  Ages = new List<integer>(); List<integer> ages = new List<integer>(){20,30,50}; Methods available in List add(Element); add(index,Element); addAll(list… Read More »