How does the final keyword not make a variable immutable? Wikipedia says it doesn’t.
How does the final keyword not make a variable immutable? Wikipedia says it doesn’t.
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.
In Java, the term final refers to references while immutable refers to objects. Assigning the
finalmodifier to a reference means it cannot change to point to another object, but the object itself can be modified if it is mutable.For example:
As the Wikipedia article mentions, if you are coming from C++, you must dissociate the concept of
constintofinaland immutable.