Link to home
Start Free TrialLog in
Avatar of johnkainn
johnkainn

asked on

loop

Is it better to instantiate a variable for each instance or outside the loop?
If it matters why.

a) Each instance
for(int i=0;i<30;i++){
   int itemId=.....;
}
b) outside the loop:
int itemId=0;
for(int i=0;i<30;i++){
   itemId=.....;
}
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial