I know this might be a stupid question to many but I usually like to stick to correct/better implementation. In Java, when writing a getter/setter, would it be better to refer to the instance variable with this or access it directly?
Thanks
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.
It does not really matter as long as you refer to the proper variables.
Yet, it is a common practice to refer to the local fields with
thisso that you do not mix them up with local variables: