Differences between passing basic data type values in java and passing array reference variables to methods

Source: Internet
Author: User

When I first entered the world of java, I found that it was so beautiful. It's still a long journey. I hope everyone can continue. For the first time I wrote a blog, I would like to give you some advice on some shortcomings.

650) this. width = 650; "src ="/e/u/themes/default/images/spacer.gif "style =" border: 1px solid # ddd; "alt =" spacer.gif "/>

class Test10{    public static void main(String[] args)    {        int[] array = {1, 2};        System.out.println("Before for swap: " + array[0] + "  " + array[1]);        swap(array[0], array[1]);        System.out.println("after for swap: " + array[0] + "   " + array[1]);        System.out.println("Before for swap: " + array[0] + "  " + array[1]);        swapFirstTwoInArray(array);        System.out.println("after for swap: " + array[0] + "   " + array[1]);                 }    public static void swap(int n1, int n2) {        int temp = n1;        n1 = n2;        n2 = n1;    }    public static void swapFirstTwoInArray(int[] array) {        int temp = array[0];        array[0] = array[1];        array[1] = temp;    }}
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/151A44V0-0.jpg "title =" 8g?tympm=?so=g=l5tce4l4.jpg "alt =" 163478169.jpg"/>


This article from the "codenong" blog, please be sure to keep this source http://yw1994.blog.51cto.com/7621136/1298271

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.