Why is the Java main method static?

前端 未结 30 2146
离开以前
离开以前 2020-11-22 01:41

The method signature of a Java main() method is:

public static void main(String[] args){
    ...
}

Is the

30条回答
  •  迷失自我
    2020-11-22 02:11

    The main() method in C++, C# and Java are static
    Because they can then be invoked by the runtime engine without having to instantiate any objects then the code in the body of main() will do the rest.

提交回复
热议问题