Java beginners about string [] args in the main method
So I'm just trying to exclude string [] args from the main method
It's assembled!
But the JVM is displaying an exception
Why compile every time string [] args is included?
What happened here? Why not show compilation errors?
Typing makes me think that the compiler may not regard it as the main method Is that so?
If so... Why not? I mean, shouldn't there be only one main method that must have string [] args as a parameter?
Solution
correct. There are no compilation errors because you are completely free to use various methods called main However, when you start the JVM and give it a "main class", it will find a method static public void main (string []) in this class. If it does not find such a method, it will abort with an exception
This allows you to have multiple main methods in your program, and if you consider it to be only meaningful: applications can consist of classes and jar files from different sources from different sources, so in many cases, you can't really have a specified "main class" from the beginning