+ Start a Discussion

Reg: Maps



Please send some simple programs to understand map concept?



Thanks & Regards:





Do you mean Google Maps or map as in a data sturcutre?


If it is google maps, are you looking for something like this:


Lucy YuanLucy Yuan


  Map is collection class.  it  is composed of unique key object and value object.


i.e  Map<integer , String > mapSample = new Map<integer , String>();

it will like a table below. 



key               value

1                    "hello world"

2                    "hello world"

3                    "hi"

..                     ..



The key for every value should be unique.

there are alreay have many method to get or  every value or key from map.map you can download  the book named "apex_language_reference". it will help you understand it well. 


Maps are collections of key-value pairs. The key for a map entry must be a primitive data type, while the value can be a primitive sObject, Apex object, or collection. You can have up to five levels of collections within a map.


You can assign key-value pairs to a map when you declare the map, with a syntax of the following :


Map<String, String> cityState = new Map<String, String>

{'Toledo' => 'Ohio', 'Chicago' => 'Illinois',

'Ann Arbor' => 'Michigan'}

Maps require the use of methods to retrieve values, and map methods are slightly different

from the common methods used by lists and sets.


For more information about methods, go through this link,