When declaring variables for a For Loop is it better to declare them at the top after the main method or only within the For Loop.
Thank you.
Proper For Loops?
Started by thieflock, Nov 12 2007 06:28 AM
2 replies to this topic
#1
Posted 12 November 2007 - 06:28 AM
|
|
|
#2
Posted 12 November 2007 - 09:17 AM
It depends on where else you will use them, and your coding style.
#3
Guest_lamagra_*
Posted 13 November 2007 - 12:04 PM
Guest_lamagra_*
thieflock is right.
If you plan to use your variable in any part of your program you need to create it outside of the loop (unless you are going to pass it to methods within the loop). If it is only being used for a counter or temp storage then do it inside the loop.
If you plan to use your variable in any part of your program you need to create it outside of the loop (unless you are going to pass it to methods within the loop). If it is only being used for a counter or temp storage then do it inside the loop.


Sign In
Create Account


Back to top









