What is public static void main(String[] args)?
Options
- The entry point: the method the JVM calls to start (Correct option)
- A required import that every Java file must contain
- A database command that starts a new connection
- A comment style that is used to document a class
Answer
The classic entry point: the method the JVM calls to start a Java program
Why
When you run java Hello, the JVM looks for a main method in that class and starts there.
- public: callable from outside the class.
- static: it belongs to the class, so no object is needed.
- void: it returns nothing.
- String[] args: the command-line arguments.
In Spring Boot, main is where SpringApplication.run(...) starts the app. JDK 25 also allows simpler forms such as void main() (JEP 512), but you will see the classic form almost everywhere.
Remember
main = where a Java program starts.