September 28th, 2013, 10:16 AM
Variable inside or outside of the loop?
Typically, a variable is used in a loop. For instance,
label = new String("xyz");
String label = new String("xyz");
Is there any efficiency difference, or preferred way to define the variable?
September 28th, 2013, 11:10 AM
Depends on the requirements. If the variable is only used inside the loop, then it should be defined inside the loop so that it goes away when the execution exits the loop.