Array reference Assignment

Source: Internet
Author: User

1  PackageCom.java7;2 3 classAssignaref {4      Public Static voidMain (string[] args) {5         inti;6         7         intNums1[] =New int[10];8         intNums2[] =New int[10];9         Ten          for(i = 0; i < i++;) OneNums1[i] =i; A          -          for(i = 0; i < i++;) -Nums2[i] =i; the          -System.out.print ("Here is nums1:"); -          for(i = 0; i < i++;) -System.out.print (Nums1[i] + ""); + System.out.println (); -          +System.out.print ("Here is NUMS2:"); A          for(i = 0; i < i++;) atSystem.out.print (Nums2[i] + ""); - System.out.println (); -          -NUMS2 = nums1;//Now Nums2 refers to Nums1 -          -System.out.println ("Here are nums2 after assignment:"); in          for(i = 0; i < i++;) -System.out.print (Nums2[i] + ""); to System.out.println (); +          -         //Now operate on sums1 array through NUMS2 theNUMS2[3] = 99; *          $System.out.println ("Here are nums1 after change through NUMS2:");Panax Notoginseng          for(i = 0; i < i++;) -System.out.print (Nums1[i] + ""); the System.out.println (); +     } A}

Execution Result:

Here is nums1:0 1 2 3 4 5 6 7 8 9
Here is nums2:0 1 2 3 4 5 6 7 8 9
Here are nums2 after assignment:
0 1 2 3 4 5 6 7 8 9
Here are nums1 after the change through NUMS2:
0 1 2 99 4 5 6 7 8 9

Array reference Assignment

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.