Problem

Complete the given apex method to find and return the number of elements in a given list.

Instructions

  • 1. The apex method must accepts a list<String> as input parameter.
  • 2. Find and return the size of the list.

Sample output

List inputList = new List ();
inputList.add('Hello');
inputList.add('World');

Integer listSize = listSizeController.findSize(inputList);
//inputList listSize is 2

Note : This exercise introduces you to writing a simple apex method to add two string values into a list. Focus on meeting the requirements, and feel free to validate your code using the execute button.

To learn more about list methods in apex, visit the official documentation here

Click here to view all apex list practice examples