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

查看:27
本文介绍了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天全站免登陆