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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.