1 public class Test2 { 2 3 public static void main(String[] args) { 4 int[] arr=new int[5]; 5 arr[0]=10; 6 arr[1]=20; 7 8 change(arr); 9 System.out.println("5:"+arr[0]);//10 10 System.out.println("6:"+arr[1]);//30 11 System.out.println("7:"+arr[2]);//89 12 System.out.println("8:"+arr[3]);//0 13 System.out.println("9:"+arr[4]);//0 14 } 15 public static void change(int[] arr){ 16 arr[1]=30; 17 arr[2]=89; 18 arr=new int[5]; 19 arr[0]=300; 20 arr[1]=900; 21 arr[2]=87; 22 arr[3]=67; 23 arr[4]=74; 24 System.out.println("0:"+arr[0]);//300 25 System.out.println("1:"+arr[1]);//900 26 System.out.println("2:"+arr[2]);//87 27 System.out.println("3:"+arr[3]);//67 28 System.out.println("4:"+arr[4]);//74 29 } 30 31 }
时间: 2024-10-22 00:37:45