1 package shuzu; 2 3 import java.util.Arrays; 4 5 public class SZ { 6 7 public static void main(String[] args) { 8 // TODO Auto-generated method stub 9 10 int arr1[] = {1,2,3,4,5}; 11 int arr2[]; 12 arr2 = Arrays.copyOf(arr1, 4); 13 for(int x : arr1) 14 { 15 System.out.println("数组arr1中元素有:"+x); 16 } 17 for(int x : arr2) 18 { 19 System.out.println("数组arr2中元素有:"+x); 20 } 21 } 22 23 }
时间: 2024-12-14 18:40:48