Java Data Transmission

Source: Internet
Author: User

1. For the original data type, that is, Int, long, Char, and other types, it is a value transfer. If you modify the value in the method, after the method call ends, the value of that variable is not changed. 2. For the object type, that is, the object subclass, If you modify the value of its member in the method, the modification takes effect. After the method call ends, its members are new values, but if you point it to another object, after the method call ends, the original reference to it does not point to the new object. The Code is as follows: public class tester {public static void main (string [] ARGs) {int primitive = 2; changeprimitive (primitive ); // The primitive value is still 2 myclass = new myclass (); changeobject (myclass); // myclass still points to the object before changeobject execution // But myclass. I equals 3} public static void changeprimitive (INT primitive) {primitive = 3;} public static void changeobject (myclass) {myclass. I = 3; myclass = new myclas S (); // here it seems to be pointing to a new referenced} class myclass {int I;} for remote calls, no matter what type, after the call ends, the passed parameters are not changed in the past. (Of course, remote methods will be called directly. If other proxy or facade classes are passed in the middle, there is no guarantee that those classes will not modify the objects ). Therefore, the call through the Local interface should also belong to the local call, which should be consistent with the above situation.

 

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.