JAVA Value Delivery

Source: Internet
Author: User

There is only one way to pass the parameters of a method in Java: value passing

Value passing: When the system starts executing a method, the system initializes the parameter to the parameter of the method, which is not the actual real parametric of the argument variable.

Reference variable: The system replicates the variable, which is the reference address, and does not copy the object itself

eg.

1 classvalue{2      Public intI=15;3 }4  Public classtest{5      Public Static voidMain (String argv[]) {6Test t=NewTest ();7 T.first ();8         }9      Public voidFirst () {Ten             intI=5; OneValue v=NewValue (); AV.i=25; - second (V.I); - System.out.println (V.I); the         } -      Public voidSecond (Value V,inti) { -I=0; -V.i=20; +Value val=NewValue (); -v=Val; +System.out.println (v.i+ "" +i); A         } at}
Results: 15 0 20

Note: V in second is not a V in first, so it's clearer to change to TMP.

JAVA Value Delivery

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.