public static void main(String[] args) { try { for (;;) { remove(); } } catch (ArrayIndexOutOfBoundsException e) { System.err.println(下标越界); } catch (InputMismatchException e) { System.err.println(请输入正整型数); } catch (Exception e) { System.err.println(错误); } finally { remove(); } } public static void remove() { System.err.print(输入测试数组长度:); Scanner sc = new Scanner(System.in); int length = sc.nextInt(); System.err.print(输入移除下标:); int index = sc.nextInt(); String[] arr = new String[length]; String[] temp = new String[arr.length - 1]; for (int i = 0; i arr.length; i++) { arr[i] = i + ; } for (int i = 0; i arr.length; i++) { if (i index) { temp[i] = arr[i]; } else if (i index) { temp[i - 1] = arr[i]; } } String out = ; for (String string : temp) { out += , + string; } out = [ + out.substring(1) + ]; System.err.println(*************88); System.err.println(out); }
取消
评论