Can there exist two main methods in a Java program?

后端 未结 16 811
后悔当初
后悔当初 2020-12-08 02:21

Can there exist two main methods in a Java program?

Only by the difference in their arguments like:

public static void main(String[] args)

16条回答
  •  遥遥无期
    2020-12-08 02:53

    The answer is no; there can only one "main" method - where "main" means an entry point you can "run".

    You can code overloaded versions as in your example, but they can't be "run".

提交回复
热议问题