What would be the reason for doing the below:
public void processSomething(final String hello, final String two, final Car car){}
as opposed to:
public void processSomething(String hello, String two, Car car){}
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 means that within the method, you can’t assign new values to the parameters.
A common reason for wanting to do this is to be able to use the parameters within anonymous inner classes which can only reference
finallocal variables, including parameters.Another reason for doing this is if your coding style favours declaring all local variables as final if possible. (Personally I try to treat them as final, but avoid actually declaring them that way, as it adds cruft.)