Out of the following, which is the preferred way of reusing the section vector?
Iterator<Vector> outputIter = parsedOutput.iterator();
while(outputIter.hasNext()) {
Vector section = outputIter.next();
}
or
Vector section = null;
while(outputIter.hasNext()) {
section = outputIter.next();
}
The second way means that the variable section is visible outside the loop. If you're not using it outside of the loop, then there's no need to do that, so use the first option. As far as performance, there shouldn't be any visible difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With