[求助]数组问题!
程序结果为什么是2,3,4,5,6呢?而不是1,2,3,4,5呢? 6是怎么得的呀?// Java Document
public class ArrayTest
{
public static void main(String [] args)
{
int[] a1 = { 1, 2, 3, 4, 5 };
int[] a2;
a2 = a1;
for(int i = 0; i < a2.length; i++)
a2[i]++;
for(int i = 0; i < a1.length; i++)
prt("a1[" + i + "] = " + a1[i]);
}
public static void prt(String s)
{
System.out.println(s);
}
}
public class ArrayTest
{
public static void main(String [] args)
{
int[] a1 = { 1, 2, 3, 4, 5 };
int[] a2;
a2 = a1;
for(int i = 0; i < a2.length; i++)
a2[i]++;
for(int i = 0; i < a1.length; i++)
prt("a1[" + i + "] = " + a1[i]);
}
public static void prt(String s)
{
System.out.println(s);
}
}