public static void main(String [] args)是否是由
Java提供的某些类的内置或用户定义或重写函数?如果在某个接口或类中声明或定义它,可以在哪里找到它的声明?
JLS 12
The Java Virtual Machine starts execution by invoking the method main of some specified class,passing it a single argument,which is an array of strings.
每个Java应用程序都应该有一个main()方法,JVM将在启动应用程序时查找main()方法.这是执行开始的地方.不,它不是内置的,你在类中定义main()方法,它成为应用程序的起始执行点. main()方法必须是public,static,return void,并接受一个参数:一个String数组.具有这种main()方法的任何类都可以用作Java应用程序的起点.
JVM spec 5.2:
The Java Virtual Machine starts up by creating an initial class,which is specified in an implementation-dependent manner,using the bootstrap class loader (§5.3.1). The Java Virtual Machine then links the initial class,initializes it,and invokes the public class method void main(String[]). The invocation of this method drives all further execution. Execution of the Java Virtual Machine instructions constituting the main method may cause linking (and consequently creation) of additional classes and interfaces,as well as invocation of additional methods.