I have define a collection like List ids. I am wondering which is better
1) initialize in the declaration
2) initialize int he constructor.
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.
You should declarate it in the constructor, not only for readability but also for inheritance matters. You might want to inherit another class from that and maybe for that particular new class you would like to overwrite the constructor because it has different parameters.