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. C++程序面试笔迹六

    1.const和static的作用 用最熟悉的语言: 2.阶乘求和  如:1!+2!+3!+4!+……+n!=sum? 3.删除掉字符串中相同的字母只留有一个  如: akkkjjtyy——> ...

  2. 利用libevent的timer实现定时器interval

    在不怎么了解libevent的情况下,看到timer这个关键字想到可以用来做定时任务,官方资料也不齐全,就从代码里看到了TIMEOUT字样,这么说来应该是支持timeout了,那interval呢,貌 ...

  3. (转)iOS7界面设计规范(4) - UI基础 - 布局

    好吧,第四篇的样子,节奏还好:我怎么又是刚吃过小龙虾的状况呢. 今天的话题是布局,篇幅很短:我自己好喜欢这样,在还有些剩余时间和精力的情况下,一个话题一个话题的推进,做做译文,并热切的希望这些内容在自 ...

  4. LoadRunner测试下载功能点脚本(方法二)

    在上一篇<LoadRunner下载功能点脚本(方法一)>中,实现的脚本仅是录制下载功能点的脚本,现在性能需求的场景更改如下: 性能需求:对系统某页面中,点击下载并将下载文件保存到本地电脑的 ...

  5. AIX 7.1 安装 Python2.7.5

    一.下载必要的安装包 1. gdbm-1.8.3-5.aix5.2.ppc.rpm  下载地址:ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolb ...

  6. ORA-24324、ORA-12560、ORA-12514

    SQL> startup ERROR: ORA-24324: 未初始化服务句柄 ORA-01041: 内部错误, hostdef 扩展名不存在. SQL> conn sys /nolog; ...

  7. nginx使用keepalived实现高可用

    环境: 主:linux-node1  110.0.0.137 备:linux-node2  110.0.0.138   VIP: 110.0.0.120   NGINX安装: # rpm -ivh h ...

  8. Linux 统计代码行数命令

    wc -l `find . -name '*.js'` wc -l `find . -regex ".*\.js"`

  9. Web Api 跨域解决方案

    一.跨域问题的由来 同源策略:出于安全考虑,浏览器会限制脚本中发起的跨站请求,浏览器要求JavaScript或Cookie只能访问同域下的内容. 正是由于这个原因,我们不同项目之间的调用就会被浏览器阻 ...

  10. ajax传递json数据,springmvc后台就收json数据

    1.ajax数据的封装 var json = {"token":token};//封装json数据 $.ajax({ url:'', data:JSON.stringify(jso ...