function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Help me understand line of code which is a method that accepts a list as a parameter

With reference to the line of code (method createContact) below I am wondering where  List<candidate_c> candidateFromTrigger is created? This doesn’t seem to follow the create new list syntax

 public void createContact(List<Candidate_c> candidateFromTrigger)

 Is this statement not required somewhere in the code to create the new List candidateFromTrigger

E.g List<candidate_c> candidateFromTrigger = new List <candidate_c>(); (I was expecting this kind of stament in the code. I am new to apex & coding)

Goal of the code:

Access method from trigger by passing to createContact

Best Answer chosen by Forcedotcom737
You don't need to initiate that variable inside your method again and its not reuqired.
The structure of the code is MethodName(Parameter type) the method create contact will accept the List of candidate record as a parameter, If you pass the list of candiadate record to that method it will store the parameter value in the variable candidateFromTrigger. You can use the same variable inside the createContact method to process your business logic.