Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0

前端 未结 3 931
一个人的身影
一个人的身影 2021-01-16 15:39
public class TestSample {
    public static void main(String[] args) {
        System.out.print(\"Hi, \");
        System.out.print(args[0]);
        System.out.prin         


        
3条回答
  •  情歌与酒
    2021-01-16 16:35

    1. The error is because no arguments were added when the program started.
    2. Since the signature of the called main method (by JVM) is public static void main(String[] args) and not public static void main(int[] args) if you want ints, you'll need to parse them from the arguments.

提交回复
热议问题