3

Map Initialization Methods in APEX

Initialisation of Maps in Apex

In Salesforce Apex, Maps are collections of key-value pairs, where each unique key maps to a single value. Initializing of Maps in Apex can be done in various ways depending on the requirements. Below are the different methods to initialize maps in Apex.

Empty Map Initialization

  1. Initialize an Empty Map of String to Integer:
Initialize an Empty Map of String to Integer
  1. Initialize an Empty Map of ID to Custom Object:
Initialize an Empty Map of ID to Custom Object

Map Initialization with Values

  1. Initialize a Map with String Keys and Integer Values:
  1. Initialize a Map with String Keys and Custom Object Values:
Initialize a Map with String Keys and Custom Object Values

Map Initialization with SOQL Query

Initialize a Map from a SOQL Query:

Initialize an Empty Map of ID to Custom Object-1

Map Methods in Apex

Following are the Map methods in Apex:

Map Methods in Apex
Next Topic

Need more support?

Get a head start with our FREE study notes!

Learn more and get all the answers you need at zero cost. Improve your skills using our detailed notes prepared by industry experts to help you excel.

Book Free15-Minutes Career Counselling