Multiple main() methods in java

后端 未结 10 627
忘了有多久
忘了有多久 2020-12-28 08:53

I was wondering what the effect of creating extra main methods would do to your code.

For example,

public class TestClass {
    public static void ma         


        
10条回答
  •  失恋的感觉
    2020-12-28 09:08

    This is perfectly fine. Having multiple main methods doesn't cause any problems. When you first start a Java program, execution begins in some function called main in a class specified by the user or by the .jar file. Once the program has started running, all the other functions called main are essentially ignored or treated like other functions.

提交回复
热议问题