Object[] objs = new Object[5];
for (int i = 0; i < 5; ++i) {
int j = i + 1;
Object obj = objs[i];
}
I have two questions for the above loop:
j
variable and obj
reference created for every loop iteration or they are created once and then only reassigned the values?++i
instead of i++
as a single instruction to increment the value?Are the j variable and obj reference created for every loop iteration or they are created once and then only reassigned the values?
Declared and created every time
Is there any perfomance benefit of putting ++i instead of i++ as a single instruction to increment the value?
Not really.
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