Explanation of 'String args[]' and static in 'public static void main(String[] args)'

java, program-entry-point

Solution

I would point a beginner to the Wiki article on the Main function, then supplement it with this.

Java only starts running a program with the specific `public static void main(String[] args)` signature, and one can think of a signature like their own name - it's how Java can tell the difference between someone else's `main()` and the one true `main()`.

`String[] args` is a collection of `String`s, separated by a space, which can be typed into the program on the terminal. More times than not, the beginner isn't going to use this variable, but it's always there just in case.

Problem

How can you explain very well, to a beginner, the meaning of `String args[]` and the use of `static` in the following excerpt? ``` class FirstApp { public static void main(String[] args) { ... } } ```

Original source

Related problems