Why is String[] args required in Java?

前端 未结 6 748
终归单人心
终归单人心 2020-12-03 21:33

I understand that String[] args is an array of strings passed into main as parameters.

java Print \"Hello, World!\"

 

         


        
6条回答
  •  春和景丽
    2020-12-03 21:50

    Because the code that runs your main() function is looking very specifically for that signature. Think of it as having, somewhere:

    YourClass.main(new String[] { ... });
    

    Obviously, if main takes anything else, this will fail.

提交回复
热议问题