For example:
public class Foo {
private int bar = 42;
Foo() {}
}
vs
public class Foo {
private int bar;
Foo() {
bar = 42;
}
}
Are there any costs / benefits between these two methods? The only way I could see that it matters is in such a scenario (where you set the value twice for the second constructor):
public class Foo {
private int bar = 42;
Foo() {}
Foo(int in) {
bar = in;
}
}
vs (where you both install it once)
public class Foo {
private int bar;
Foo() {
this(42);
}
Foo(int in) {
bar = in;
}
}
Am I missing something? Is there any inherent value in this, anyway?
Edit
Well, I understand that they are functionally equivalent. I am trying to find out if there are significant processing costs associated with one over the other. It seems that at best it should be careless, but I would like to confirm my suspicions.
Edit 2
, . . , , .