Because val is similar to final in Java, should most Java object references be marked as final as using val is good practice in Scala?
Share
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.
Certainly it’s good practice to make class variables
finalin Java, encouraging immutability wherever possible.As for whether local variables — method parameters, etc. — should be marked final when not necessary, that’s a question of style. Personally, I feel it tends to clutter things when used, unless it’s otherwise necessary (e.g. to make a variable accessible in an anonymous inner class).