A loop uses a loop variable to store the values for the current record in the collection. When the loop completes taking action on the one-loop
record, Salesforce then places the next record into the loop variable.
Let’s get some in-hand practice on loops, In order to solve some complex queries in salesforce.