package:the library unit

The levels of access control from "most access" to "least access" are public, protected, package access(which has no keyword), and private.

Each compilation unit must hava a name ending in .java, and inside the complication unit there can be a public class that must hava the same name as the file(including capitalization, but excluding the .java file name extension). There can be only one public class in each compilation unit; otherwise, the compiler will complain. If there are additional classes in that compilation unit, they are hidden from the world outside that package because they’re not public, and they comprise "support" classes for the main public class.

Java access specifiers

|_protected: inheritance access

Sometimes the creator of the base class would like to take a particular member and grant access to derived classes but not the world in general. That’s what protected does. protected also gives package access-that is, other classes in the same package may access protected elements.

Class access

倒包的一些限制:

1、There can be only one public class per compilation unit(file). The idea is that each compilation unit has a single public interface represented by that public class. It can hava as many supporting package- access as you want. If you hava more than one public class inside a compilation unit, the compiler will give you an error message.

2、The name of the public class must exactly match the name of the file containing the compilation unit, including capitalization. So for Widget, the name of the file must be Widget.java, not widget.java or WIDGET.java. Again, you’ll get a compile-time error if they don’t agree.

3、It is possible, thought not typical, to hava a compilation unit with no public class at all. In this case, you can name the file whatever you like(although naming it arbitrarily will be confusing to people reading and maintaining the code).



 

TIJ——Chapter Six:Access Control的更多相关文章

  1. [C++] OOP - Access Control and Class Scope

    Access Control And Inheritance Protected Member Like private, protected members are unaccessible to ...

  2. In c++ access control works on per-class basis not on per-object basis.

    #ifndef MYTIME_H #define MYTIME_H class MyTime { private: int m_hour; int m_minute; public: MyTime() ...

  3. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' heade

    XMLHttpRequest cannot load http://10.164.153.37:8050/WebService/WebService.asmx/wsGetStreetData. Res ...

  4. Windows Azure Virtual Network (10) 使用Azure Access Control List(ACL)设置客户端访问权限

    <Windows Azure Platform 系列文章目录> 本文介绍的是国内由世纪互联运维的China Azure. 我们在创建完Windows Azure Virtual Machi ...

  5. SELINUX、Security Access Control Strategy && Method And Technology Research - 安全访问控制策略及其方法技术研究

    catalog . 引言 . 访问控制策略 . 访问控制方法.实现技术 . SELINUX 0. 引言 访问控制是网络安全防范和客户端安全防御的主要策略,它的主要任务是保证资源不被非法使用.保证网络/ ...

  6. Linux VFS Extended Attribute And Access Control Table

    catalog . 简介 . 扩展属性 . 访问控制表 . 小结 0. 简介 许多文件系统都提供了一些特性,扩展了VFS层提供的标准功能,虚拟文件系统不可能为所有特性都提供具体的数据结构.超出标准的U ...

  7. RBAC(Role-Based Access Control,基于角色的访问控制)

    RBAC(Role-Based Access Control,基于角色的访问控制),就是用户通过角色与权限进行关联.简单地说,一个用户拥有若干角色,每一个角色拥有若干权限.这样,就构造成“用户-角色- ...

  8. 转:Oracle R12 多组织访问的控制 - MOAC(Multi-Org Access Control)

    什么是MOAC MOAC(Multi-Org Access Control)为多组织访问控制,是Oracle EBS R12的重要新功能,它可以实现在一个Responsibility下对多个Opera ...

  9. Server-Side Access Control

    Firefox 3.5 implements the W3C Access Control specification.  As a result, Firefox 3.5 sends specifi ...

随机推荐

  1. Servlet开发总结(一)

    一.Servlet简介 Servlet是sun公司提供的一门用于开发动态web资源的技术. Sun公司在其API中提供了一个servlet接口. 用户若想用发一个动态web资源(即开发一个Java程序 ...

  2. 【python之路35】FTP文件断电续传作业

    开发一个支持多用户在线FTP程序: 要求: 1.用户MD5加密认证 2.允许同时多用户登陆(socketserver) 3.执行命令 4.上传文件 文件传输过程中显示进度条 支持文件的断点续传

  3. [转]js设计模式-策略模式

    在程序设计中,常常遇到类似的情况,要实现某一个功能有多种方案可以选择.比如一个压缩文件的程序,既可以选择zip算法,也可以选择gzip算法.这些算法灵活多样,而且可以随意互相替换.这种解决方案就是本文 ...

  4. cookie记录

    登录页面引用: <script src="/jquery.cookie.js"></script> 登录页面jq: var telphone = $('[n ...

  5. Xshell 、PuTTY 复制文件到Linux

    一.使用Xshell 在linux下下载一个需要安装一个工具lrzsz包: [root@localhost home] # yum install -y lrzsz 从windows上传文件到linu ...

  6. angular 项目迭代+记录采坑

    年中的时候 正在做的项目来了新的领导 给我们的NG4项目来了一次大整顿. 我们公司项目基本都是敏捷开发--> 开发出一个成熟的shared目录(里面有所有的公用组件 公用服务 公用工具类) 然后 ...

  7. vue打包之部署在非根路径下的三两事

    首先,感叹一下,2019年已经过去一半,想想自己做了些什么,好像也没做什么. 今天试着配一个nginx,以前的nginx都是指向的/根路径,今天的nginx指向的非/根路径,遇到许多问题的,总结总结. ...

  8. java如何使用 tesseract 4.0.0-1.4.4

    提示: 建议直接使用tess4j,tess4j是对tesseract的封装,使用更简单 首先引入依赖 <!-- https://mvnrepository.com/artifact/org.by ...

  9. tomcat的访问日志

    https://blog.csdn.net/qq_30121245/article/details/52861935 配置位置在这里,每一个域名设置都可以单独设置 %a   这是记录访问者的IP,如果 ...

  10. Boost Asio教程集合

    http://zh.highscore.de/cpp/boost/ 第七章 https://mmoaay.gitbooks.io/boost-asio-cpp-network-programming- ...