Can the main( ) method be specified as private or protected?

前端 未结 5 588
余生分开走
余生分开走 2020-12-18 04:24

Can the main() method be specified as private or protected?

Will it compile?

Will it run?

5条回答
  •  孤城傲影
    2020-12-18 04:37

    Yes, it will compile. But it wil not run as entry point of the program.

    Java looks for the public main method signature. If any of the modifiers is different, then it wil assume it as some other method.

    run and test 4 urself. :)

提交回复
热议问题