java中数组的引用

时间:2015-11-13 12:58:40

标签: java arrays

    public class sss {

  public static void main(String[] args) {
    int[] array = { 1, 2, 3 };
    change(array);

    for(int i=0;i<array.length;i++)
        System.out.println(array[i]);

  }

  public static void change(int [] array)
  {
      int[] temp = new int[4];
      for (int i =0; i<temp.length;i++)
          temp[i] = i;
      array =  temp;
  }

}

我试图改变我的阵列, 为什么输出是1,2,3而不是0,1,2,3? 感谢。

0 个答案:

没有答案