public static void main(String arg[ ] ) in java is it fixed?

前端 未结 9 1391
离开以前
离开以前 2020-12-03 03:25

I was recently asked in an exam if public static void main(String arg[]) format of main method was fixed? Can we change it? Can we use main

9条回答
  •  余生分开走
    2020-12-03 04:16

    The main method must be public so it can be found by the JVM when the class is loaded. Similarly, it must be static so that it can be called after loading the class, without having to create an instance of it. All methods must have a return type, which in this case is void.

提交回复
热议问题