List in Salesforce

By | March 3, 2020

List

  1. It allows Duplicate values .
  2. It maintains insertion order.
  3. List maintains index based.
  4. It allows multiple null values.

Syntax

List<Datatype> variable name = new List<Datatype>();

Examples

  • List<integer> a = new List<integer>();
  • List<Account> b = new List<Account>();
  • List<integer> ages;  Ages = new List<integer>();
  • List<integer> ages = new List<integer>(){20,30,50};

Methods available in List

  1. add(Element);
  2. add(index,Element);
  3. addAll(list 1);
  4. size();
  5. set(index,Element);
  6. remove(index);
  7. clear();l
  8. get(index);
  9. isEmpty();
  10. SORT();

Leave a Reply

Your email address will not be published. Required fields are marked *