Effects of the final modification method passed in Java

Source: Internet
Author: User

Recently in the spring source depth analysis See the many methods of the parameters are modified by the final modifier what role is it not allowed to modify parameters in the method?

I checked the net.

Final type decorated parameters are divided into two types of basic types and reference types

Final decoration basic types are as follows

<span style= "White-space:pre" ></span>public void GetValue (final int a) {   <span style= "White-space: Pre "></span>....<span style=" White-space:pre "></SPAN>}
If you modify the parameters of the above method in the method, you will get an error such as

Final Modified Reference type

     public void GetValue (final Integer a) {         ...     }
If you modify the referenced object, you will also be prompted for the above error.

But in a different way

public void GetValue (final contract C) {c.hourspanname= "AA";}
There's no problem.
I have summed up the next 1, within the parameters of the call, whether it is a basic type or a reference type whose value is immutable (reference type refers to a reference object is not changed)

2. Variable attribute in reference type

3.

Effects of the final modification method passed in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.