修饰符总结 Modifiers
        函数修饰符始终在返回值类型之前!!!
        变量修饰符始终在变量类型之前!!!
--------------------------------------------------------------------------------
ClassModifier: one of
Annotation public protected private
abstract static final strictfp
        外部类: 不可被 protected, private, static 和 final 修饰
        成员内部类: 都可以
        非成员内部类: 都不可以

FieldModifier: one of
Annotation public protected private
static final transient volatile

MethodModifier: one of
Annotation public protected private
abstract static final synchronized native strictfp

ConstructorModifier: one of
Annotation public protected private

InterfaceModifier: one of
Annotation public protected private
abstract static strictfp

VariableModifier: one of
Annotation final
--------------------------------------------------------------------------------
                                                        class        field        method        constructor        interface        variable
Annotation                                        √                √                √                √                        √                        √

public/protected/private        √                √                √                √                        √                        ×

abstract/strictfp                        √                ×                √                ×                        √                        ×

static                                                √                √                √                ×                        √                        ×

final                                                √                √                √                ×                        ×                        √

transient/volatile                        ×                √                ×                ×                        ×                        ×

synchronized/native                        ×                ×                √                ×                        ×                        ×
--------------------------------------------------------------------------------
Annotation
        以上都可以
public/protected/private
        权限修饰符, 除了 variable 都可以 ->常考
abstract/strictfp
        class/interface/method
static
        除了 constructor 和 variable 都可以 -> 常考
final
        除了 constructor 和 interface 都可以
transient/volatile
        只能修饰 field
synchronized/native
        只能修饰 method
--------------------------------------------------------------------------------
final 与 abstract 是冲突的.

--------------------------------------------------------------------------------
/*
包与包之间成员和构造器的访问权限总结:
                                public                protected        无修饰符        private
同一个类中                ok                        ok                        ok                        ok
同一个包中                ok                        ok                        ok
不同包子类                ok                        ok
不同包中                ok

不同包成员访问的前提: 被访问的类必须是 public, 且被访问的成员也必须是 public 的
不同包中的子类还可以直接访问父类中 protected 的成员和构造器

不同包访问, 有2层权限限制: 
        第1层是类的权限限制, 类的权限可以是 public/无权限修饰符2种
        第2层是成员的权限限制, 成员的权限可以是 public/protected/无权限修饰符/private 等4种
        必须类的权限允许访问, 才考虑成员的权限是否允许访问!!!

实际编程中, 访问的类一般都是不同包的:
        类是 public 的, 构造器是 public 的, 
                允许被不同包的类创建对象; 否则禁止被不同包的类创建对象
        类是 public 的, 构造器是 protected 的
                只允许被不同包的类继承(就是设计来被继承的, 此时不允许被不同包的类创建对象)
        类是 public 的, 构造器是 private 的(一般也是 final 的)
                不允许被创建对象(包括本包的类都不行), 此时一般提供 public 方法获取类的对象

不同包中, protected 的作用就是限制成员和构造器只能被子类访问;
同一包中, protected 修饰成员变量和构造函数时没任何作用, 修饰成员函数时仅仅限于覆盖.
*/

AJPFX关于modifier总结的更多相关文章

  1. [转]Java反射之如何判断类或变量、方法的修饰符(Modifier解析)

    Java针对类.成员变量.方法,有很多修饰符,例如public.private.static.final.synchronized.abstract等,这些修饰符用来控制访问权限或其他特性. 本文就用 ...

  2. jmeter 中的 HTTP URL Re-writing Modifier

    URL rewriting modifier,因为tomcat的session实现不是通过cookie的,而是通过session id的,就是说,用户登录有了session之后,tomcat就会维护一 ...

  3. 【转载】#273 - Parameter Modifier Summary

    Here's a summary of the different parameter modifiers and how the behavior changes for each, when us ...

  4. 解决Deprecated: preg_replace(): The /e modifier is deprecated, use

    使用php5.5运行ecshop的时候出现如下错误Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace ...

  5. 7.modifier插件的自定义和使用

    1.在plugins下面创建一个文件 modifier.changeDate.php 编写: <?php function smarty_modifier_changeDate($utime,$ ...

  6. Sample Code for Qp_preq_pub.Price_request Api to Simulate an Ask for Promotion Modifier

    DECLARE p_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE; p_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE; p_line_attr_tbl ...

  7. java反射(java.lang.reflect)---java.lang.reflect.Modifier中状态码

    1. 详情请看jvm(虚拟机)规范 java.lang.reflect.Modifier public static final int ABSTRACT 1024 public static fin ...

  8. An entry point cannot be marked with the 'async' modifier

    I copied below code from this link.But when I am compiling this code I am getting an entry point can ...

  9. AJPFX简述:MetaTrader 4移动交易平台

    (AJPFX)移动交易平台可以让客户随时通过客户手中的移动设备例如智能手机.PDA等管理自己帐户和进行交易.移动交易平台提供了完整的交易帐户管理分析选项,当客户无法使用台式计算机的时候,移动交易平台为 ...

随机推荐

  1. 读取本地json文件,转出为指定格式json 使用Base64进行string的加密和解密

    读取本地json文件,转出为指定格式json   引用添加Json.Net 引用命名空间 using Newtonsoft.Json //读取自定目录下的json文件StreamReader sr = ...

  2. Handlebars.js 中文文档

    Home  »  前端   »   Handlebars.js 中文文档 Handlebars.js 中文文档 Posted in 前端 By KeenWon On 2014年4月3日 Views:  ...

  3. Leetcode Single Number II (面试题推荐)

    还记得<剑指offer>和<编程之美>等书上多次出现的找一个数组中仅仅出现一次的数那个题吗? leetcode也有这道题 链接here  相信大家都知道用异或在O(n)的时间复 ...

  4. 给GridView设置行高

    近期在工作中遇到了这样一个问题,使用一个GridView展示数据,item中仅仅是一个TextView,可是里面显示的文字多少不固定多少,必须所有展示出来. 遇到的问题: 1.把item中的宽和高设置 ...

  5. 2016/2/29 html 思维导图

  6. HDU 5405 Sometimes Naive 树链剖分+bit*****

    Sometimes Naive Problem Description   Rhason Cheung had a naive problem, and asked Teacher Mai for h ...

  7. Adding Security to an Existing Website

    The procedure earlier in this article relies on using the Starter Site template as the basis for web ...

  8. Mac mysql 运行sql文件中文乱码的问题

    别再傻傻的改什么mysql的编码格式了. 是.sql文件的编码有问题,把sql文件的编码格式改成utf-8就行了. mac怎么修改呢? vscode最爽了. 用vscode打开.sql文件,然后点右下 ...

  9. POJ1733 Parity game —— 种类并查集

    题目链接:http://poj.org/problem?id=1733 Parity game Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  10. ubuntu1.8安装lnmp失败

    兴致冲冲的安装好ubuntu1.8. 想安装lnmp,结果失败,失败,失败. 一遍由一遍,很痛苦. 每一遍都要半个小时,甚至更久. 等来的就是失败. 看日志也看不出头绪来. ============= ...