Can there exist two main methods in a Java program?

后端 未结 16 783
后悔当初
后悔当初 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 03:01

    Case :1 > We have two main method but with "Main" AND "main2" so jvm only a=calling "main" method .

    2> Same method but diff params, still jvm calling "main(String[] args) " meyhod.

    3> Exactly same method but it gives copile time error as you can not have two same name method in a single class !!!

    Hope it will give you clear pic

提交回复
热议问题