A summary of two ways to transfer function parameters in Java

Source: Internet
Author: User

Similar to the method of passing function parameters in C + +, Java has 3 kinds of parameter passing methods because there is no concept of pointers in the language system, and there are only two types of java. Here is a little bit of my experience:

are: reference type passing and basic data type delivery. Reference passing is essentially not a newly created object, but instead declares another reference to point to the same object. The parameter pass for the base data type is the value pass, and the other copy is copied in memory. Here is the code explanation:

1  PackageASGH;2 3  Public classRefdemo {4 5      Public Static voidMain (string[] args) {6 Student Zs;7zs=NewStudent ();8Zs.name= "Zhangsan";9 A (ZS);Ten System.out.println (zs.name); One          A         int[] arr=New int[] {1,2,3,4,5,6}; - B (arr); -System.out.println (arr[0]); the          -         inti=100; -         intj=200; - c (i,j); +System.out.println (i+ "" +j); -  +     } A  at      Public Static voidCintIintj) { -         intTemp=0; -temp=i; -I=J; -j=temp; -          in     } -  to      Public Static voidbint[] arr) { +arr[0]=300; -          the     } *  $      Public Static voidA (Student zs) {Panax NotoginsengZs.name= "Lisi"; -          the     } +  A } the  + classstudent{ - String name; $     intAge ; $ String address; -}

A summary of two ways to transfer function parameters 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.