Wednesday, January 18, 2023

List in Salesforce

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();

No comments:

Post a Comment