fork(1) download
  1. import java.util.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) throws NumberFormatException {
  5. String[] s = {"あ", "い", "う", "え", "お"};
  6. ArrayList<String> arr = new ArrayList<>();
  7. for(String str : s){
  8. arr.add(str);
  9. }
  10. int index = Integer.parseInt(args[0]);
  11. if (args.length != 1 || (index != 0 && index != 1 && index != 2 && index != 3 && index != 4)){
  12. System.exit(1);
  13. }
  14. arr.remove(index);
  15. System.out.println(arr);
  16. }
  17. }
  18.  
Runtime error #stdin #stdout #stderr 0.05s 2184192KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
	at Main.main(Main.java:10)