public class copy {
public static void main(String[] args) {
int [] arry1 = {1, 2, 3, 4, 5};
int [] arry2 = copy(arry1);
for (int i = 0; i < arry2.length; i++)
{
System.out.println("arry2数组中第" + (i+1) + "位的值为:" + arry2[i]);
}
}
public static int[] copy(int[] arry1)
{
int [] arry2 = new int[arry1.length];
for (int i = 0; i < arry1.length; i++)
{
arry2[i] = arry1[i];
}
return arry2;
}
}
java将数组1复制给数组2
最新推荐文章于 2024-08-19 16:01:20 发布