A beginner’s error (args[0]) [duplicate]

I started to read a book on java, and there the author showed this program. But I get errors in the line with args[0]. The author writes that this line has to read string. Is it true?

public class Main {

public static void main(String[] args) {

    System.out.println(args[0]);

    System.out.println("Amazing");
}
}

The error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Main.main(Main.java:5)

Leave a Comment