修饰符总结 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. BZOJ 1122 POI2008 账本BBB 单调队列

    题目大意:给定一个由+1和−1构成的长度为n的序列,提供两种操作: 1.将某一位取反,花销为x 2.将最后一位移动到前一位.花销为y 要求终于p+sumn=q.且p+sumi≥0(1≤i≤n),求最小 ...

  2. 安装SQLserver2008时出现的错误

    1.SQLserver2008提示必须重新启动计算机才干够继续安装.解决方法例如以下: 在開始->执行中输入regedit,到HKEY_LOCAL_MACHINE\SYSTEM\CurrentC ...

  3. devres in linux driver

    写 driver 时, probe 中常常要为设备分配一些资源, 如 内存 / irq / gpio / iomap 等. 而在 probe 中失败时又要小心的释放掉这些资源. 底层驱动开发人员可能会 ...

  4. 使用word模板生成pdf文件

    使用word模板生成pdf文件 源码:UserWord

  5. Codeforces 768 E. Game of Stones 博弈DP

    E. Game of Stones   Sam has been teaching Jon the Game of Stones to sharpen his mind and help him de ...

  6. struts2 Action获取表单数据

    1.通过属性驱动式 1.首先设置 表单中的数据的name值 如:<input type="text" name="username" value=&quo ...

  7. ES6 模块化(Module)export和import详解 export default

    ES6 模块化(Module)export和import详解 - CSDN博客 https://blog.csdn.net/pcaxb/article/details/53670097 微信小程序笔记 ...

  8. H264编码器性能測试

    版本号:0.1.0-beta 作者:石硕 更新:2014-04-13 15:54:08 ======================================================== ...

  9. mac系统下如何删除银行安全插件

    要分类解决了,一般safair插件都是pkg包安装的 如果:1.制作者够良心,PKG安装包中植入了删除卸载功能,那就好办了,打开当时安装的pkg包,执行删除选项 2.没良心的,装了不好删的,我目前个人 ...

  10. BZOJ_1670_[Usaco2006 Oct]Building the Moat护城河的挖掘_求凸包

    BZOJ_1670_[Usaco2006 Oct]Building the Moat护城河的挖掘_求凸包 Description 为了防止口渴的食蚁兽进入他的农场,Farmer John决定在他的农场 ...