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. spring MVC4 配置详解(个人记录)

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  2. mysql建表设置格式

    建表时必须设置字段编码格式为COLLATE utf8_bin,表示查询时该字段内容区分大小写,如果不需要区分大小写,可以设置为COLLATE utf8_ genera_ci,表示忽略大小写

  3. 设置mysql二进制日志过期时间

    ((none)) > show variables like 'expire_logs_days'; +------------------+-------+ | Variable_name | ...

  4. MySQL8.0.17 - Multi-Valued Indexes 简述

    本文主要简单介绍下8.0.17新引入的功能multi-valued index, 顾名思义,索引上对于同一个Primary key, 可以建立多个二级索引项,实际上已经对array类型的基础功能做了支 ...

  5. 洛谷 P3956 棋盘

    题目描述 有一个m ×m的棋盘,棋盘上每一个格子可能是红色.黄色或没有任何颜色的.你现在要从棋盘的最左上角走到棋盘的最右下角. 任何一个时刻,你所站在的位置必须是有颜色的(不能是无色的), 你只能向上 ...

  6. dp入门 hdu2059 龟兔赛跑

    龟兔赛跑 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  7. 直接在安装了redis的Linux机器上操作redis数据存储类型--对Sorted-Sets操作

    一.概述: Sorted-Sets和Sets类型极为相似,它们都是字符串的集合,都不允许重复的成员出现在一个Set中.它们之间的主要差别是Sorted-Sets中的每一个成员都会有一个分数(score ...

  8. 学习JDK1.8集合源码之--PriorityQueue

    1. PriorityQueue简介 PriorityQueue是一种优先队列,不同于普通队列的先进先出原则,优先队列是按照元素的优先级出列,每次出列都是优先级最高的元素.优先队列的应用很多,最典型的 ...

  9. 2019-9-2-C#判断文件是否被混淆

    title author date CreateTime categories C#判断文件是否被混淆 lindexi 2019-09-02 12:57:37 +0800 2018-2-13 17:2 ...

  10. JavaScript 报错 注释