+ Start a Discussion
Srinivas TestingSrinivas Testing 

How to check for loop count in apex class?

Best Answer chosen by Srinivas Testing
Glyn Anderson 3Glyn Anderson 3
There no built-in way to know which loop iteration you're on.  You have to keep track of it yourself.  Something like the code below:

<pre>
Integer loopCount = 0;
for ( Object obj : listOfObjects )
{
    // do stuff here...
    loopCount++;
}
</pre>

All Answers

Glyn Anderson 3Glyn Anderson 3
There no built-in way to know which loop iteration you're on.  You have to keep track of it yourself.  Something like the code below:

<pre>
Integer loopCount = 0;
for ( Object obj : listOfObjects )
{
    // do stuff here...
    loopCount++;
}
</pre>
This was selected as the best answer
Glyn Anderson 3Glyn Anderson 3
Srinivas,  Did this answer solve your problem?  If so, please mark the question as "Solved".  If not, let us know.  If you solved it yourself a different way, please post your solution.  Thanks!
Directory LibDirectory Lib
Hello, nice post! Thank you! 
 SEO Tools, SEO Analysis, SEO Analyzer, SEO Website, website checker, seo tools, website ranking, seo checker, website analytics, website analysis, seo optimizer, site worth, seo site checkup, website analyzer, seo online, seo check, free seo website report, backlink generator (https://www.directorylib.com)
Sarah JamesSarah James
i really like your post.
Best Bronzer For Fair Skin 2021: From Pale To Fair Skin (https://womenhealthome.com/best-bronzer-for-fair-skin/)
How To Lose Weight Naturally At Home Remedy (https://womenhealthome.com/how-to-lose-weight-naturally-at-home-remedy/)
 
TonystkTonystk
Aadhar Card Verify kaise kare online UIDAI ke site se, How To verify Aadhar Card, aadhar card verification https://aadhaarsewa.in/verify-aadhar-card-number-online/
alex julletalex jullet
I also want to add the Loop style in my website of Talib, see here more detail (https://talib.pk/).
Quiz CurryQuiz Curry
Thanks for the information provided . it has helped me on my personal blog (https://quizcurry.com/flipkart-daily-trivia-quiz-answers/).
Behzad AslamBehzad Aslam
Very Useful Information.

Unlike other posts, I have been reading on different blogs yours is impressive and the information is so detailed and written with expertise. As a school or intermediate student, perhaps students are searching for date sheet for their exams here is the latest news and updates for students,<a href="https://eduhub.pk/date-sheets-all-boards-matric-inter-bachelors-masters/">Pakistan All Boards Date Sheet</a>.You can visit our website and you will find there all the information you need.

<a href="https://eduhub.pk/date-sheets-2020-all-boards-punjab-sindh-kpk-other-eduhub/">Pakistan All Boards Date Sheet</a>