Notes
In Apex, the indexOf(listElement)
method is used to find the first occurrence of a specified element in a list and return its index. If the element is not found in the list, the method returns -1.
Here's an example:
List<Integer> numberList = new List<Integer>{1, 2, 3, 4, 5};
Integer indexOfElement3 = numberList.indexOf(3);
System.debug('Index of element 3: ' + indexOfElement3);
Output: Index of element 3: 2
Video
Video does not exists.