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);
- Set<key> keyset(); used to read all keys.
- Remove(key);
- Size();
Example
Map<string,integer> m = new map<string,integer>();
m.put(‘salesforce’, 200);
m.put(‘codes’ 300);
system.debug(‘map values’ +m);