{"id":213,"date":"2022-09-26T10:00:00","date_gmt":"2022-09-26T04:30:00","guid":{"rendered":""},"modified":"2023-07-04T19:25:08","modified_gmt":"2023-07-04T13:55:08","slug":"salesforce-apex-collections-list-set-map","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/","title":{"rendered":"Salesforce Apex Collections : List, Set, Map"},"content":{"rendered":"<div style=\"clear: both; text-align: center;\"><\/div>\n<h1 style=\"text-align: left;\">Salesforce Collections: List, Set, Map<\/h1>\n<p>Collections are the group of similar types. There is no limit on the number of items a collection can hold. However, there is a general limit on heap size.<\/p>\n<p>There are three types of Salesforce collections.<\/p>\n<ol style=\"text-align: left;\">\n<li>List<\/li>\n<li>Set<\/li>\n<li>Map<\/li>\n<\/ol>\n<h3 style=\"text-align: left;\">1. List:<\/h3>\n<p><b>List<\/b> is an <b>ordered collection<\/b> of elements which will allow duplicates.<br \/>\nA list is an ordered collection of typed primitives SObjects, user-defined objects, Apex objects or collections that are distinguished by their includes.<\/p>\n<div>\n<ul style=\"text-align: left;\">\n<li>The index position of the first element in a list is always &#8216;0&#8217;<\/li>\n<li>List elements can be of any data type: primitive types, collections, sObjects, user-defined types, and built-in Apex types.<\/li>\n<li>A list is an ordered collection of elements that are distinguished by their indices.<\/li>\n<li>To declare a list, use the list. keyword followed by the primitive data, SObject, nested list, map, or set type within &lt; &gt;characters.<\/li>\n<\/ul>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>List Syntax:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>List&lt;datatype&gt; listName = new List&lt;datatype&gt;();<\/code><\/pre>\n<div>Note:-<br \/>\nSimilar to lists, map values can contain any collection and can be nested within one another. A map can only contain up to five levels of nested collections inside it.<\/div>\n<div><\/div>\n<div>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Example 1:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>List&lt;String&gt; lstStr = new List&lt;String&gt;();\n\/\/ If \" = new List&lt;String&gt;() \" not defined then got NullPointer error\n\/\/ eg. List&lt;String&gt; lstStr;\n\/\/ System.NullPointerException: Attemp to de-reference a null object.\n\n\/\/ Add value into List veriable\nlstStr.add('ABCD');\nlstStr.add('EFGH');\nlstStr.add('IJKL');\nlstStr.add('MNOP');\n\n\/\/ print List veriable\nSystem.debug(lstStr);\n\n\/\/ After execute this code into anonymous window\n\/\/ Output: (ABCD,EFGH,IJKL,MNOP)<\/code><\/pre>\n<\/div>\n<div>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Example 2:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>List&lt;String&gt; lstStr = new List&lt;String&gt;{'ABCD','EFGH','IJKL','MNOP'};\nSystem.debug(lstStr);\n\n\/\/ After execute this code into anonymous window\n\/\/ Output: (ABCD,EFGH,IJKL,MNOP)<\/code><\/pre>\n<\/div>\n<div style=\"text-align: left;\">\n<div style=\"font-size: medium; font-weight: 400;\">\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Example 3:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>List&lt;String&gt; lstStr = [SELECT Id, Name, Amount FROM Opportunity WHERE StageName = 'Closed Won'];\nSystem.debug(lstStr);\nSystem.debug(lstStr.size()); \/\/ get count of elements that are present in List\n\n\/\/ After execute this code into anonymous window\n\/\/ Output: All list of opportunity having StageName = Closed Won<\/code><\/pre>\n<\/div>\n<\/div>\n<div><\/div>\n<div style=\"text-align: left;\">\n<p style=\"color: #1e1e1e; font-size: 16px; font-weight: 400; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Some Example:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px; font-weight: 400; text-align: left;\"><code>List&lt;Integer&gt; rollNumbers = new List&lt;Integer&gt;{1230001, 1230002, 1230003};\nSystem.debug(rollNumbers);\n\n\/\/ <i>get item on index 1<\/i>\nInteger rollNum = rollNumbers.get(1);\nSystem.debug(rollNum);\nSystem.debug(rollNumbers.get(1));\n\n\/\/ <i>add item on index 4<\/i>\nrollNumbers.add(4, 2220001);\nSystem.debug(rollNumbers);\n\n\/\/ <i>get the list size<\/i>\nSystem.debug(rollNumbers.size());\n\n\/\/ <i>remove the item on index 3<\/i>\nrollNumbers.remove(3);\nSystem.debug(rollNumbers);\nSystem.debug(rollNumbers.size());\n\n\/\/ <i>update item on index 1<\/i>\nrollNumbers.set(1, 3330001);\nSystem.debug(rollNumbers);\n\n\/\/ <i>clear the list<\/i>\nrollNumbers.clear();\nSystem.debug(rollNumbers);\nSystem.debug(rollNumbers.size());\n\n\/\/ <i>below line will throw an error<\/i>\nrollNumbers.set(1, 3330001);\nSystem.debug(rollNumbers);\n<\/code><\/pre>\n<\/div>\n<div style=\"text-align: left;\"><span style=\"font-size: medium; font-weight: normal;\"><span style=\"font-size: medium; font-weight: normal;\"><br \/>\n# Click here : <a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_list.htm\" target=\"_blank\" rel=\"nofollow noopener\">More Details about List Methods<\/a>&nbsp;&nbsp;<\/span><\/span><\/p>\n<\/div>\n<p>2. Set:<\/p>\n<p><b>Set <\/b>is an <b>unordered collection<\/b> of elements which will not allow duplicates.<br \/>\nA set is an unordered collection of primitives or SObjects that do not contain any duplicate elements.To declare a set, use the set keyword followed by the primitive data type name within &lt; &gt; characters.<\/p>\n<ul style=\"text-align: left;\">\n<li>Data type allows only primitive datatypes and SObjects.<\/li>\n<li>Set elements can be of any data type: primitive types, collections, sObjects, user-defined types, and built-in Apex types.<\/li>\n<li>A set is an unordered collection of elements that do not contain any duplicates.<\/li>\n<li>We cannot get the retrieve the data based on index because set does not&nbsp; have index.<\/li>\n<\/ul>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Set Syntax:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>Set&lt;datatype&gt; setName = new Set&lt;datatype&gt;();<\/code><\/pre>\n<div><code><code><\/code><\/code><\/p>\n<p><code><code><\/code><\/code><\/p>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Some Examples:<\/u><br \/>\n<\/span><\/p>\n<p><code><code><\/code><\/code><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>Set&lt;Integer&gt; rollNumbers = new Set&lt;Integer&gt;{1008890, 1008100, 1007231};\nSystem.debug(rollNumbers);\n\nrollNumbers.add(9897767);\nrollNumbers.add(9897764);\nrollNumbers.add(9897765);\n\nSystem.debug(rollNumbers);\n\n\/\/ adding duplicate values - NOT ALLOWED\nrollNumbers.add(9897767);\nSystem.debug(rollNumbers);\n\n\/\/ check if set has an item\nSystem.debug(rollNumbers.contains(9897764));\nSystem.debug(rollNumbers.contains(9345345));\n\n\/\/ delete an item\nrollNumbers.remove(9897765);\nSystem.debug(rollNumbers);\n\n\/\/ get set size\nSystem.debug(rollNumbers.size());\n\n\/\/ check if set is empty\nSystem.debug(rollNumbers.isEmpty());\n\n\/\/ remove all items\nrollNumbers.clear();\nSystem.debug(rollNumbers.isEmpty());\n<\/code><\/pre>\n<p><code><code><\/code><\/code><\/p>\n<div><code>&nbsp;<\/code><\/div>\n<p><code><span style=\"font-size: large;\"># Click here :&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_set.htm\" target=\"_blank\" rel=\"nofollow noopener\">More Details about Set Methods<\/a><\/span><span style=\"font-size: large;\"><br \/>\n<\/span><br style=\"font-size: large;\"><\/code><\/p>\n<\/div>\n<h2 style=\"text-align: left;\">3. Map:<\/h2>\n<p><b>Map<\/b> stores <b>key-value<\/b> pairs. A map is a collection of <b>key-value<\/b> pairs where each unique key maps to a single value. Keys can be any primitive datatype while values can be primitive, sobject, collection type or Apex object.<\/p>\n<ul>\n<li>To declare a map, use the Map keyword followed by the data types of the value within&nbsp; &lt; &gt; characters.<\/li>\n<li>A map is a collection of key-value pairs where each unique key maps to a single value.<\/li>\n<li>Keys and values can be any data type: primitive types, collections, sObjects, user-defined types, and built-in Apex types.<\/li>\n<li>datatype_key is the storage datatype of key and it allows only primitive datatypes and should be unique.<\/li>\n<li>datatype_value is the datatype of value. Both primitive &amp; non-primitive datatypes are allowed. Duplicates are allowed for values.<\/li>\n<li>The iteration order of map elements is deterministic. You can rely on the order being the same in each subsequent execution of the same code. However, we recommend to always access map elements by key.<\/li>\n<li>A map key can hold the null value.<\/li>\n<li>Adding a map entry with a key that matches an existing key in the map overwrites the existing entry with that key with the new entry.<\/li>\n<li>Map keys of type String are case-sensitive. Two keys that differ only by the case are considered unique and have corresponding distinct Map entries. Subsequently, the Map methods, including put, get, containsKey, and remove treat these keys as distinct.<\/li>\n<\/ul>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Map Syntax:<\/u><br \/>\n<\/span><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>Map&lt;datatype_key,datatype_value&gt; mapName = new Map&lt;datatype_key,datatype_value&gt;();<\/code><\/pre>\n<div><code><code><\/code><\/code><\/p>\n<p><code><code><\/code><\/code><\/p>\n<p style=\"color: #1e1e1e; font-size: 16px; margin: 0px 0px 1rem; padding: 0px;\"><span style=\"color: black; font-size: medium;\"><u>Some Examples:<\/u><br \/>\n<\/span><\/p>\n<p><code><code><\/code><\/code><\/p>\n<pre style=\"color: #1e1e1e; font-size: 16px;\"><code>Map&lt;Integer, String&gt; testCls = new Map&lt;Integer, String&gt;();\n\n\/\/ add a new student\/item\ntestCls.put(12300001, 'Swapnil');\nSystem.debug(testCls);\n\ntestCls.put(12300002, 'Harry');\ntestCls.put(12300003, 'Rick');\ntestCls.put(12300004, 'Bill');\nSystem.debug(testCls);\n\ntestCls.put(12300005, 'Bill');\nSystem.debug(testCls);\n\n\/\/update\/override value\ntestCls.put(12300005, 'Skywalker');\nSystem.debug(testCls);\n\n\/\/ get a value\nSystem.debug(testCls.get(12300003));\n\n\/\/ remove an item from map\ntestCls.remove(12300002);\nSystem.debug(testCls);\n\n\/\/ get all the keys\nSet&lt;Integer&gt; rollNumber = testCls.keySet();\nSystem.debug(rollNumber);\n\n\/\/ get all the values\nList&lt;String&gt; students = testCls.values();\nSystem.debug(students);\n\n\/\/ check if map has the key\nSystem.debug(testCls.containsKey(12300002));\n<code>System.debug(testCls<\/code>.containsKey(12300003));\n\n<\/code><\/pre>\n<p><code><span style=\"font-size: large;\"># Click here :&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_map.htm\" target=\"_blank\" rel=\"nofollow noopener\">More Details about Map Methods<\/a>&nbsp;&nbsp;<\/span><br style=\"font-size: large;\"><\/code><\/p>\n<\/div>\n<div><\/div>\n<h2 style=\"text-align: left;\">Resources:<\/h2>\n<div style=\"text-align: left;\"><span style=\"font-size: medium;\">&nbsp;# <a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/langCon_apex_collections_lists.htm\" target=\"_blank\" rel=\"nofollow noopener\">Collection: List<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_list.htm\" target=\"_blank\" rel=\"nofollow noopener\">List Class Methods<\/a>&nbsp;<\/span><\/p>\n<div><span style=\"font-size: medium;\">&nbsp;#&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/langCon_apex_collections_sets.htm\" target=\"_blank\" rel=\"nofollow noopener\">Collection: Set<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_set.htm\" target=\"_blank\" rel=\"nofollow noopener\">Set Class Methods<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/langCon_apex_collections_maps.htm\" target=\"_blank\" rel=\"nofollow noopener\">Collection: Map<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_map.htm\" target=\"_blank\" rel=\"nofollow noopener\">Map Class Methods<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/swapnilzambare.com\/blog\/blog\/2022\/05\/12\/soql-salesforce-object-query-language-in-apex\/\" target=\"_blank\" rel=\"nofollow noopener\">SOQL in Apex<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/object-oriented-programming-for-admins\/use-a-for-loop-to-iterate-through-a-list\" target=\"_blank\" rel=\"nofollow noopener\">Trailhead Module : List<\/a><br \/>\n#&nbsp;<a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/object-oriented-programming-for-admins\/define-sets-and-maps\" target=\"_blank\" rel=\"nofollow noopener\">Trailhead Module : Set, Map<\/a>&nbsp;<\/span><\/div>\n<\/div>\n<h3 style=\"text-align: left;\"><span style=\"font-size: small; font-weight: normal;\">&nbsp;<\/span><\/h3>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Salesforce Collections: List, Set, Map Collections are the group of similar types. There is no limit on the number of items a collection can hold. However, there is a general limit on heap size. There are three types of Salesforce collections. List Set Map 1. List: List is an ordered collection of elements which will&#8230;<\/p>\n","protected":false},"author":2,"featured_media":83,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,17,18],"tags":[],"class_list":["post-213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apex","category-collection","category-salesforce-developer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Salesforce Apex Collections : List, Set, Map - Swapnil SFDC | Salesforce Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Salesforce Apex Collections : List, Set, Map - Swapnil SFDC | Salesforce Blog\" \/>\n<meta property=\"og:description\" content=\"Salesforce Collections: List, Set, Map Collections are the group of similar types. There is no limit on the number of items a collection can hold. However, there is a general limit on heap size. There are three types of Salesforce collections. List Set Map 1. List: List is an ordered collection of elements which will...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil SFDC | Salesforce Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-26T04:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-04T13:55:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"525\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SwapnilZambare7\" \/>\n<meta name=\"twitter:site\" content=\"@SwapnilZambare7\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/\",\"url\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/\",\"name\":\"Salesforce Apex Collections : List, Set, Map - Swapnil SFDC | Salesforce Blog\",\"isPartOf\":{\"@id\":\"https:\/\/swapnilzambare.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png\",\"datePublished\":\"2022-09-26T04:30:00+00:00\",\"dateModified\":\"2023-07-04T13:55:08+00:00\",\"author\":{\"@id\":\"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/8ababd34e5d3bc24fa10df2a87c5ac45\"},\"breadcrumb\":{\"@id\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#primaryimage\",\"url\":\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png\",\"contentUrl\":\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png\",\"width\":750,\"height\":525,\"caption\":\"Swapnil SFDC Salesforce Blog\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/swapnilzambare.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Salesforce Apex Collections : List, Set, Map\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/swapnilzambare.com\/blog\/#website\",\"url\":\"https:\/\/swapnilzambare.com\/blog\/\",\"name\":\"Swapnil SFDC | Salesforce Blog\",\"description\":\"Hey trailblazers, Welcome to Swapnil SFDC world.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/8ababd34e5d3bc24fa10df2a87c5ac45\",\"name\":\"Swapnil\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/50610dedda801c6c795bfc5b650f7f4ed5f7c34b3b5c9c7148d702eb351c003b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/50610dedda801c6c795bfc5b650f7f4ed5f7c34b3b5c9c7148d702eb351c003b?s=96&d=mm&r=g\",\"caption\":\"Swapnil\"},\"url\":\"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Salesforce Apex Collections : List, Set, Map - Swapnil SFDC | Salesforce Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/","og_locale":"en_US","og_type":"article","og_title":"Salesforce Apex Collections : List, Set, Map - Swapnil SFDC | Salesforce Blog","og_description":"Salesforce Collections: List, Set, Map Collections are the group of similar types. There is no limit on the number of items a collection can hold. However, there is a general limit on heap size. There are three types of Salesforce collections. List Set Map 1. List: List is an ordered collection of elements which will...","og_url":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/","og_site_name":"Swapnil SFDC | Salesforce Blog","article_published_time":"2022-09-26T04:30:00+00:00","article_modified_time":"2023-07-04T13:55:08+00:00","og_image":[{"width":750,"height":525,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png","type":"image\/png"}],"author":"Swapnil","twitter_card":"summary_large_image","twitter_creator":"@SwapnilZambare7","twitter_site":"@SwapnilZambare7","twitter_misc":{"Written by":"Swapnil","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/","url":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/","name":"Salesforce Apex Collections : List, Set, Map - Swapnil SFDC | Salesforce Blog","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png","datePublished":"2022-09-26T04:30:00+00:00","dateModified":"2023-07-04T13:55:08+00:00","author":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/8ababd34e5d3bc24fa10df2a87c5ac45"},"breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2022\/08\/sflogo-e1688320096934.png","width":750,"height":525,"caption":"Swapnil SFDC Salesforce Blog"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/salesforce-apex-collections-list-set-map\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Salesforce Apex Collections : List, Set, Map"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil SFDC | Salesforce Blog","description":"Hey trailblazers, Welcome to Swapnil SFDC world.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/8ababd34e5d3bc24fa10df2a87c5ac45","name":"Swapnil","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/50610dedda801c6c795bfc5b650f7f4ed5f7c34b3b5c9c7148d702eb351c003b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/50610dedda801c6c795bfc5b650f7f4ed5f7c34b3b5c9c7148d702eb351c003b?s=96&d=mm&r=g","caption":"Swapnil"},"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":3,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":340,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/213\/revisions\/340"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/83"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}