import java.util.Scanner;
public class Eext {
public static void main(String[] args) {
//数组扩容
int[] arr = {1,2,3};
int[] arr2 = new int[arr.length + 1]; //定义了一个arr容量加一的数组
for (int i = 0; i < arr.length; i++) {
arr2[i] = arr[i]; //将arr的值 赋给arr2
}
arr2[arr2.length - 1] = 4; //把 4 赋给 arr2 的最后一个元素
arr = arr2; //让arr 指向 arr2
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]); //遍历arr
}
}
}