为什么主要方法被标记为公开? [英] Why main method is marked as public?

查看:160
本文介绍了为什么主要方法被标记为公开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,为什么主要方法标记为公开

I have a question that why main method is marked as public?

根据stackoverflow的答案,它被声明为 static

According to an answer on stackoverflow, It is declared as static



该方法是静态的,否则会有歧义:哪个构造函数应该被称为

"The method is static because otherwise there would be ambiguity: which constructor should be called?"


但是,任何人都可以解释为什么声明公开总是?

But, can anyone can explain why it is declared public always?

推荐答案

启动程序的初始化软件必须能够看到 main 以便它可以调用它。

The initialization software that starts your program must be able to see main so that it can call it.

这篇关于为什么主要方法被标记为公开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆