Java Language Foundation Study questions parameter passing problem in Java

Source: Internet
Author: User

1 /*2 3 the value of the base data type is passed without changing the original value, because the stack is played after the call and the local variable disappears4 the value of the reference data type is passed, changing the original value, because even if the method is on the stack, but the heap memory array object is still in, you can continue to access through the address5 6 the value that the base data type passes to the parameter7 the address to which the reference data type is passed to the parameter8 9 But the address is also a value, so the argument is passed, and the pass is the value.Ten  One */ A  -  - classdemo5{ the      Public Static voidMain (string[] args) { -             intA = 10; -             intb =20; -  +System.out.println ("A:" +a+ "B:" +b); - Change (A, b); +System.out.println ("A:" +a+ "B:" +b); A  at             int[] arr = {1,2,3,4,5}; -System.out.println (arr[1]); -  -     } -  -      Public Static voidChangeintAintb) { inSystem.out.println ("A:" +a+ "B:" +b); -A =b; tob = A +b; +System.out.println ("A:" +a+ "B:" +b); -     } the  *      Public Static voidChangeint[] arr) { $          for(inti=0;i<arr.length;i++){Panax Notoginseng             if(arr[x]%2==0){ -arr[x]*=2; the             } +         } A     } the}

Java Language Foundation Study questions parameter passing problem 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.