There are three methods in Batch Apex.
- Start: This method is called at the very beginning and it is used to collect the records through query or objects to be passed to the execute method.
Syntax: global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
- Execute: We use this method to do required processing for every chunk of data.
Syntax: global void execute(Database.BatchableContext BC, list<ListOfRecords>){}
- Finish: This method is executed after all the batches are processed. We can use this method to send email confirmations or execute post processing operations.
Syntax: global void finish(Database.BatchableContext BC){}