Activity Forums Salesforce® Discussions What is the difference between List, Map and Set in Salesforce?

  • Kirandeep

    Member
    February 7, 2020 at 2:51 pm

    The list is a type of ordered collection that maintains the elements in insertion order, Set is a type of unordered collection and Map is a collection of key-value pairs.

     

    • This reply was modified 4 years, 10 months ago by  Forcetalks.
  • Arun

    Member
    February 10, 2020 at 12:31 pm

    Hi Pooja,

    List- A list is an ordered collection of elements that are distinguished by their indices. List elements can be of any data type—primitive types, collections, sObjects.

    Set- A set is an unordered collection of elements that do not contain any duplicates. Set elements can be of any data type—primitive types, collections, sObjects.

    Map- A map is a collection of key-value pairs where each unique key maps to a single value. Keys and values can be any data type—primitive types, collections, sObjects.

     

  • Shweta

    Member
    February 10, 2020 at 1:01 pm

    List: This is the most common collection data type. It includes a sort() method, so we use a list whenever we need something to be ordered.

    Set: Sets are unordered collection and It enforces uniqueness (it means, used to prevent duplicates in our code).

    Map: It is a collection that consists of key-value pairs.

    • Keys - It behaves like a set (which is unique).
    • Values - It behaves like a list.
    • This reply was modified 4 years, 10 months ago by  Forcetalks.
    • This reply was modified 4 years, 10 months ago by  Forcetalks.
  • Anjali

    Member
    February 10, 2020 at 2:19 pm

    List- it is an ordered collection.

    Set- it is an unordered collection.

    Map- it is a collection of key-value pairs.

    • This reply was modified 4 years, 10 months ago by  Forcetalks.

Log In to reply.

Popular Salesforce Blogs