package test; import java.util.Scanner; public class fasd { public int[] insertData(int length) { int[] arr=new int[length]; Scanner sc=new Scanner(System.in); for(int i=0;i<arr.length;i++) { System.out.println("请键入第"+(i+1)+"个元素"); arr[i]=sc.nextInt(); } System.out.println("数组元素为:"); for (int i : arr) { System.out.print(i + " "); }System.out.println(); return arr; } public static void main(String[] args) { int[] array = new int[5]; Scanner sc = new Scanner(System.in); fasd asd = new fasd(); asd.insertData(5); for (int i : array) { System.out.print(i + " "); } System.out.println(); } }
qq_与赠_03193390
相关分类