Referrence: Oracle Java Doc

Two levels

top level: public, or package-private (no explicit modifier)

member level: public, private, protected, package-private (no explicit modifier)

Three Modifiers & Four Access Control Types

1. public

A class/ member may be declared with the modifier public, in which case that class is visible to all classes everywhere.

2. package-private (no explicit modifier)

If a class/ member has no modifier (the default, also known as package-private), it is visible only within its own package.

3. private

The private modifier specifies that the member can only be accessed in its own class.

4. protected

The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

Access Levels Chart

1st col: Whether the class itself has access to the member defined by the access level.

2nd col: Whether classes in the same package as the class (regardless of their parentage) have access to the member.

3rd col: Whether subclasses of the class declared outside this package have access to the member.

4th col: Whether all classes have access to the member.

Controlling Access in Java的更多相关文章

  1. StreamSets学习系列之启动StreamSets时出现Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "test.to.ensure.security.is.configured.correctly" "read")错误的解决办法

    不多说,直接上干货! 问题详情 [hadoop@master streamsets-datacollector-]$ ./bin/streamsets dc Java 1.8 detected; ad ...

  2. java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")

    转自:https://blog.csdn.net/bluecard2008/article/details/80921682?utm_source=blogxgwz0 摘要: 今天在使用jetty做容 ...

  3. access denied ("java.net.SocketPermission" "localhost:1527" "listen,resolve")

    在开启derby服务出现该错误(测试hibernate 连接数据库时  使用myeclipse2014自带的数据库--windows->show view->other->Myecl ...

  4. 保护代理模式-Access Proxy(Java实现)

    保护代理模式-Access Proxy 保护代理模式(Access Proxy), 也叫Protect Proxy. 这种代理用于对真实对象的功能做一些访问限制, 在代理层做身份验证. 通过了验证, ...

  5. atorg.apache.hadoop.io.nativeio.NativeIO$Windows.access(NativeIO.java:557)

    错误原因: 你当前开发环境中{Hadoop_HOME}\bin\hadoop.dll 文件和你当前的hadoop版本不匹配.  解决方案: 网络下载相应版本的hadoop.dll,并将该文件放入c:\ ...

  6. windows elasticsearch使用ik分词器插件后启动报错java.security.AccessControlException: access denied ("java.io.FilePermission" "D:...........\plugins\ik-analyzer\config\IKAnalyzer.cfg.xml" "read")

    删除es安装文件夹中空格,遂解决......(哭

  7. Using Java SecurityManager to grant/deny access to system functions

    In Java it is possible to restrict access to specific functions like reading/writing files and syste ...

  8. Error updating database. Cause: java.sql.SQLException: Access denied for user '${username}'@'localhost' (using password: YES)

    导入别人的项目,出现一个错误,经过排查,是db.properties配置文件中的用户名与Mybatis-conf.xml配置文件中调用的用户名不一致所导致的 (db.properties中用的是nam ...

  9. Java程序生成一个Access文件

    package access; import java.io.File;import java.io.IOException;import java.sql.SQLException;import j ...

随机推荐

  1. IEEE论文格式要求

    0.特别提示:本次会议要求各位作者根据审稿意见进行认真修改,然后经过大会主席的检查合格才允许上传IEEE eXpress,主要的目的是为了保证论文集的质量,不让论文格式出现五花八门的情况,确保会议后被 ...

  2. Hybrid App开发模式中, IOS/Android 和 JavaScript相互调用方式

    IOS:Objective-C 和 JavaScript 的相互调用 iOS7以前,iOS SDK 并没有原生提供 js 调用 native 代码的 API.但是 UIWebView 的一个 dele ...

  3. Webservice-Java-CXF

    1)首先呢,还是包的问题,在http://cxf.apache.org/download.html这里可以下到最新版的CXF,当然,我用的是最新版的.接下来还是那句废话,建WEB项目,放入JAR包.而 ...

  4. Linux系统相关

    1. 图形界面启动的是哪个运行级别? 而我们平时用的命令行模式又是哪个运行级别? 除了图形和命令行模式两个常用级别外,其他运行级别代表什么涵义?如何更改系统的运行级别?图形界面启动的是5级别,命令行模 ...

  5. http status 源码

    private static readonly String[][] s_HTTPStatusDescriptions = new String[][] { null, new String[] { ...

  6. (转).net控件dropdownlist动态绑定数据

    DropDownList控件的使用(数据绑定)(.net学习笔记二)(2006-10-12 07:28:49) 转载   分类:.net学习笔记 一.在页面初始化时候将集合绑定到DropDownLis ...

  7. C#中new和override的区别

    override是指“覆盖”,是指子类覆盖了父类的方法.子类的对象无法再访问父类中的该方法.(签名必须相同) new是指“隐藏”,是指子类隐藏了父类的方法,当然,通过一定的转换,可以在子类的对象中访问 ...

  8. 18 java 代理模式 (转)

    静态代理 1.新建一个接口,这个接口所提供的方法是关于数据库操作的 public interface EmployeeDao { public void updateSalary(); } 2.建一个 ...

  9. K-D Tree题目泛做(CXJ第二轮)

    题目1: BZOJ 2716 题目大意:给出N个二维平面上的点,M个操作,分为插入一个新点和询问到一个点最近点的Manhatan距离是多少. 算法讨论: K-D Tree 裸题,有插入操作. #inc ...

  10. js字符串数字计算

    1.字符串转换为数字用 -0 var a=1; var b='2'; var c= a+b;(12) var c=a+(b-0);(3)