Open Nav

Java访问权限修饰词

以下是资料介绍,如需要完整的请充值下载.
1.无需注册登录,支付后按照提示操作即可获取该资料.
2.资料以网页介绍的为准,下载后不会有水印.仅供学习参考之用.
   帮助中心
资料介绍:

Java访问权限修饰词(中文5100字,英文3700字)
public、protected和private这几个Java访问权限修饰词在使用时,置于类中每个成员的 定义之前的-无论它是一个域还是一个方法。每个访问权限修饰词仅控制它所修饰的特定定义的 访问权。
如果不提供任何访问权限修饰词,则意味着它是“包访问权限”。因此,无论如何,所有事 物都具有某种形式的访问权限控制。在以下几节中,读者将学习各种类型的访问权限。
包访问权限
包访问权限允许将包内所有相关的类组合起来,以使它们彼此之间可以轻松地相互作用。 当把类组织起来放进一个包内之时,也就给它们的包访问权限的成员赋予了相互访问的权限, 你“拥有” 了该包内的程序代码。“只有你拥有的程序代码才可以访问你所拥有的其他程序代码”, 这是合理的。应该说,包访问权限为把类群聚在一个包中的做法提供了窓义和理由。在许多语 言中,在文件内组织定义的方式是任意的,但在Java中,则要强制你以一种合理的方式对它们 加以组织。另外,你可能还想要排除这样的类-它们不应该访问在当前包中所定义的类。

Java access specifiers
The Java access specifiers public, protected, and private are placed in front of each definition for each member in your class, whether it’s a field or a method. Each access specifier only controls the access for that particular definition. [资料来源:https://www.doc163.com]
If you don’t provide an access specifier, it means “package access.” So one way or another, everything has some kind of access control. In the following sections, you’ll learn about the various types of access.
Package access
Package access allows you to group related classes together in a package so that they can easily interact with each other. When you put classes together in a package, thus granting mutual access to their package-access members, you “own” the code in that package. It makes sense that only code that you own should have package access to other code that you own. You could say that package access gives a meaning or a reason for grouping classes together in a package. In many languages the way you organize your definitions in files can be arbitrary, but in Java you’re compelled to organize them in a sensible fashion. In addition, you’ll probably want to exclude classes that shouldn’t have access to the classes being defined in the current package. [资料来源:https://www.doc163.com]
 

[版权所有:http://DOC163.com]

上一篇:对象的创建和存在时间

下一篇:安卓应用程序基础

  • 关于资料
    提供的资料属本站所有,真实可靠,确保下载的内容与网页资料介绍一致.
  • 如何下载
    提供下载链接或发送至您的邮箱,资料可重复发送,若未收到请联系客服.
  • 疑难帮助
    下载后提供一定的帮助,收到资料后若有疑难问题,可联系客服提供帮助.
  • 关于服务
    确保下载的资料和介绍一致,如核实与资料介绍不符,可申请售后.
  • 资料仅供参考和学习交流之用,请勿做其他非法用途,转载必究,如有侵犯您的权利或有损您的利益,请联系本站,经查实我们会立即进行修正! 版权所有,严禁转载
    doc163.com Copyright © 2012-2024 苏ICP备2021029856号-4