Java中的默认访问说明符是什么? [英] What is the default access specifier in Java?

查看:102
本文介绍了Java中的默认访问说明符是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始读一本Java书籍,就纳闷了。

I just started reading a Java book and wondered; which access specifier is the default one, if none is specified?

推荐答案

默认的可见性称为 package-private(尽管您不能明确地使用它),这意味着可以从该类所属的同一包内部访问该字段。

The default visibility is known as "package-private" (though you can't use this explicitly), which means the field will be accessible from inside the same package to which the class belongs.

如mdma所指出的那样,不过,对于接口成员而言,它不是真的,默认值为 public。

As mdma pointed out, it isn't true for interface members though, for which the default is "public".

请参见 Java的访问说明

这篇关于Java中的默认访问说明符是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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