public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入数组");
ArrayList<Integer> list = new ArrayList<>();
while(sc.hasNext()) {
int num = sc.nextInt();
if(num == -99999) {
break;
}
list.add(num);
}
int[] arr = new int[list.size()];
for (int i = 0; i < arr.length; i++) {
arr[i] = list.get(i);
}
}
Of course, the value of -99999 is only one never to appear.