Collection Data Types in Salesforce
Collection-- A collection is a group of similar type element. It is the framework that provides Classes and Interfaces for grouping of the similar type elements. There are three types of collection in Apex-- 1. List-- A list is the ordered collection of elements which are distinguished by their index. List element can be of any data type(Integer, String, or sObject). so use list collection whenever you want to identify an element by their index. List<String> sList = new List<String>(); sList.add('Jon'); sList.add('smith'); system.debug(sList.size()); 2. Set-- A set is an unordered collection of elements that don't contain any duplicate element. Set can be any dataType (Integer, String, or sObject). So use set when you don't want any duplication in your collection. Set<String> str = new Set<String>(); str.add('Jane'); str.add('...