Sorry, but I couldn’t think of anything better. Could you help me understand the difference between these two scenarios.
public class Temp {
int value;
public Temp(int i) {
this.value = i;
}
public void method(Vector<Temp> vec) {
Temp temp=null;
for (int i = 0; i < 10; i++) {
temp = new Temp(i);
vec.add(temp);
}
for (int i = 0; i < 10; i++) {
Temp temp1 = new Temp(i);
vec.add(temp1);
}
}
}
Which implementation should be best practice.
source
share