import java.util.Scanner; public class Eext { public static void main(String[] args) { int[] oldArr = {7,77,777}; A03 a03 = new A03(); int[] newArr = arr.copyArr(oldArr); for (int i = 0; i < newArr.length; i++) { System.out.print(newArr[i] + " "); } } } //编写类A03,实现数组复制功能,输入一个旧的数组返回一个新的数组 元素和旧元素一样 //1.方法的返回类型 int[] //2.方法的名字 copyArr //3.方法的形参 int[] //4.方法体 复制一个数组 class A03 { public int[] copyArr(int[] oldArr) { int[] newArr = new int[oldArr.length]; for (int i = 0; i < oldArr.length; i++) { newArr[i] = oldArr[i]; } return newArr; } }
标签:copyArr,int,newArr,复制,数组,A03,oldArr From: https://www.cnblogs.com/shuqiqi/p/16980679.html