Is java “public static void main (string [] args)” the only way to create a main method?

I wonder if "Java main method" is the only way to create a main method in Java

Java main methods:

Solution

The JVM needs an entry point to start execution. This entry point is defined in the JVM as follows

public static void main(String [] args)

Therefore, to answer your question, you can define the main method with any access modifier or with / without the static keyword, but it is not a valid main method, because the main method used by the JVM as an entry point should be defined as this

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>