博客
关于我
Java访问权限深入
阅读量:349 次
发布时间:2019-03-04

本文共 1557 字,大约阅读时间需要 5 分钟。

Java???????????

??????????Java???????????????????????????????Java???????????????


??public??????

??:

public??????????????public???????????????????

????:

  • ????Java??????????????public???????????????
  • ???????????public???????????????
  • ???public????????????
  • ????:

    public class PublicClass {    public int value = 10; // ??????????????    public void method() { // ??????????????        System.out.println("Public method called");    }}

    ??protected???????

    ??:

    protected??????????????????protected??????????????????????????????????

    ????:

  • ????????????protected??
  • ????????????????protected???
  • ???protected??????????
  • ????:

    protected class ProtectedClass extends PublicClass {    protected void protectedMethod() {        System.out.println("Protected method called");    }}

    ??friendly??????

    ??:

    friendly???????????????????friendly????????????????

    ????:

  • ????????????friendly??
  • ?????????????friendly???
  • ??????????????????friendly???
  • ????:

    class FriendlyClass {    friendly void friendlyMethod() {        System.out.println("Friendly method called");    }}

    ??private??????

    ??:

    private??????????private???????????????

    ????:

  • ????????????private??
  • ???????????private???
  • ?????????private???
  • ????:

    private class PrivateClass {    private int privateKey = 123; // ????????PrivateClass???    private void privateKeyMethod() {        System.out.println("Private method called");    }}

    ?????????????

    public > protected > friendly > private

    ?????????

  • ??????????????????????????????????????????????????????????
  • ??????????????????????????????????

  • ?????????????????????????????????????

    转载地址:http://tpke.baihongyu.com/

    你可能感兴趣的文章
    NFS网络文件系统
    查看>>
    nft文件传输_利用remoting实现文件传输-.NET教程,远程及网络应用
    查看>>
    ng 指令的自定义、使用
    查看>>
    Nginx
    查看>>
    nginx + etcd 动态负载均衡实践(二)—— 组件安装
    查看>>
    nginx + etcd 动态负载均衡实践(四)—— 基于confd实现
    查看>>
    Nginx + Spring Boot 实现负载均衡
    查看>>
    Nginx + uWSGI + Flask + Vhost
    查看>>
    Nginx - Header详解
    查看>>
    Nginx Location配置总结
    查看>>
    Nginx upstream性能优化
    查看>>
    Nginx 中解决跨域问题
    查看>>
    Nginx 动静分离与负载均衡的实现
    查看>>
    Nginx 反向代理 MinIO 及 ruoyi-vue-pro 配置 MinIO 详解
    查看>>
    Nginx 反向代理解决跨域问题
    查看>>
    Nginx 反向代理配置去除前缀
    查看>>
    nginx 后端获取真实ip
    查看>>
    Nginx 学习总结(17)—— 8 个免费开源 Nginx 管理系统,轻松管理 Nginx 站点配置
    查看>>
    nginx 常用配置记录
    查看>>
    Nginx 我们必须知道的那些事
    查看>>