About value passing or reference passing in Java

Source: Internet
Author: User

There are many examples on the internet, I am lazy, do not write an example, write their feelings.

In Java, it is a value pass or a reference pass, which I think is not very important, but what is important is the understanding of delivery.

The parameters in the method are divided into two types

  1. Basic data types
  2. Reference data types (classes, interfaces, arrays)

When a parameter is a base data type, the JVM copies the argument value, which is the value of the variable, to the parameter, and any operation on the formal parameter in the method does not affect the actual parameter value;

When a parameter is a reference data type, the JVM copies the argument object, the address value, to the parameter, and the parameters and arguments to the memory in the same heap, which can change the value in the memory, affect the argument, but if the memory that the parameter points to changes, the action on the parameter in the method does not affect the argument.

can look at (ox _ Ox). NET article http://www.cnblogs.com/SilentCode/p/4858790.html

About value passing or reference passing 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.