DEV Community

Sonali Gupta
Sonali Gupta

Posted on

iconic lines...of java

✔️ public – open to everyone (even JVM)

✔️ static – can run without creating an object

✔️ void – doesn’t return anything

✔️ main – starting point of every Java program

✔️ String[] args – takes command-line input if passed

🔹 Can we remove String[] args from main in Java?
Technically — NO, you should not remove it.
The correct signature that the JVM looks for is:

Image description
This is the standard method signature that the JVM recognizes to start your Java program.

❌ If you remove it like this:

Image description

🧨 What will happen?

✅ It will compile successfully (no syntax error).

❌ But when you run it using:

Image description

✅ Why does JVM expect String[] args?
JVM needs to pass command-line arguments, even if you don’t use them.

That’s why the method must be defined with that exact signature.

Top comments (0)