Map is a collection of class, which consists a group of elements. It is a key and value pair. Each and every element in the map contains key and value. Key should be unique and value can be duplicated. It supports dynamic memory allocation. It's like a acollection of Key-value pair, where each key(unique) map to a single value. Keys and values can be any data types.
Syntax:
Map<Key,Value> variablename=new Map<Key,Value>();
In salesforce, we have standard object Account, If we want to map id with account, it is represented as,
Map<Id,Account> Accmap=new Map<Id,Account>();
It returns the value with given key in the map.
Ex:
Map<String, String> mapname=new Map<String, String>();
mapname.put('red','shirt');
mapname.put('blue','tshirt');
mapname.put('black','shirt');
When the above is executed with both mapname.keyset() and mapname.values() method we will get the values as for keyset:{red, blue, black}
for values:{shirt, tshirt, shirt}.
From this, we can see that values can be duplicated.
If we try to duplicate key, it overrides the existing key and gives the output with the key that is given at last.
It removes all the key-value mapping pairs from the map.
It returns the value to which the key is mapped, or it generates null if the key has no value.
It returns the set of keys that contain in the map.
It returns the set of values that contain in the map.
It returns the number of key-value pairs in the map.
It returns the duplicate copy of the map.
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.
Django-CRM :Customer relationship management based on Django
Django-blog-it : django blog with complete customization and ready to use with one click installer Edit
Django-webpacker : A django compressor tool
Django-MFA : Multi Factor Authentication
Docker-box : Web Interface to manage full blown docker containers and images
More...