What is the difference between:
public class A
{
private int x = 1;
A() {}
}
and
public class A
{
private int x;
A() { x = 1; }
}
, if any?
If you are asking from a practical point of view, the difference is that with the second form of initialization you will have to repeat it for every constructor that you write, were you to write many overloaded constructors.
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