This course is currently a work in progress. Please join the waitlist to receive regular updates.

Finding list size

To find the number of elements(size) of a list in apex, use the size() method.

Following is an example of finding the size of a list:

Loading...

In the above example:

  • The size() method is used to find the number of elements in a list.
  • The size() method can be applied to list variables and does not require any input parameters.

Note


The list must be initialized before applying the size() method to avoid a null pointer exception.

Try It Yourself

Loading...