You need to sign in to do that
Don't have an account?
system.debug in for loop: does it work only on very last loop?
Hello Dev Community,
within "Developer Trail - Beginner" Module "Apex Basics & Database" I have started step "Getting Started with Apex".
From topic "Apex Collections: List" I try to execute some commands of that example as static method. This is the coding of my very first apex program:

Now I am stuck with this: only the last System.debug statement for color "blue" is executed:

May I ask for some help, please:
How (if ever) can I get all 3 colors shown in debug log?
How should I code this program more professionally?
within "Developer Trail - Beginner" Module "Apex Basics & Database" I have started step "Getting Started with Apex".
From topic "Apex Collections: List" I try to execute some commands of that example as static method. This is the coding of my very first apex program:
Now I am stuck with this: only the last System.debug statement for color "blue" is executed:
May I ask for some help, please:
How (if ever) can I get all 3 colors shown in debug log?
How should I code this program more professionally?
I would say that I would rewrite this method as follows:
or even better
All Answers
I would say that I would rewrite this method as follows:
or even better
thank you for your help. This was exactly what I was waiting for. It has helped me to develop some understanding for Apex.