Problem
Complete the given apex method to add an element at a specific index on a list.
Instructions
- The apex method must accepts three parameters. A list<String>, String and Integer as an input parameter.
- The first parameter is a list<String> which is the input list.
- The second parameter is a string value, which needs to be added to the list.
- The third parameter is a an integer, the index in which the value needs to be added to the list.
- Return the list in response.
Sample output
List
//listX[0] will be 'hello'
Note : This exercise introduces you to writing a simple apex method to add a string values into a list by index. 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.