Wednesday, January 18, 2023

Map in Salesforce

Map

  1. It is key value pair.
  2. Key must be primitive data type and value may be primitive data types/Reference data type.
  3. Primitive data type are integer,decimal,string,id,Boolean,data…
  4. 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

  1. Put(key,value);
  2. Set<key> keyset(); used to read all keys.
  3. Remove(key);
  4. Size();

Example

Map<string,integer> m = new map<string,integer>();

m.put(‘salesforce’, 200);

 m.put(‘codes’ 300);

system.debug(‘map values’ +m);

No comments:

Post a Comment

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC)

Understanding Wire vs Imperative Apex Method Calls in Salesforce Lightning Web Components (LWC) Introduction: Salesforce Lightning Web ...