JLS中给出的Java类对象初始化顺序
来源:互联网 发布:java循环嵌套 编辑:程序博客网 时间:2024/06/05 23:03
引用自 section 12.5 of the Java Language Spec:http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.5
Just before a reference to the newly created object is returned as the result, the indicated constructor is processed to initialize the new object using the following procedure:
1. Assign the arguments for the constructor to newly created parameter variables for this constructor invocation.
2. If this constructor begins with an explicit constructor invocation (§8.8.7.1) of another constructor in the same class (using this), then evaluate the arguments and process that constructor invocation recursively using these same five steps. If that constructor invocation completes abruptly, then this procedure completes abruptly for the same reason; otherwise, continue with step 5.
3. This constructor does not begin with an explicit constructor invocation of another constructor in the same class (using this). If this constructor is for a class other than Object, then this constructor will begin with an explicit or implicit invocation of a superclass constructor (using super). Evaluate the arguments and process that superclass constructor invocation recursively using these same five steps. If that constructor invocation completes abruptly, then this procedure completes abruptly for the same reason. Otherwise, continue with step 4.
4. Execute the instance initializers and instance variable initializers for this class, assigning the values of instance variable initializers to the corresponding instance variables, in the left-to-right order in which they appear textually in the source code for the class. If execution of any of these initializers results in an exception, then no further initializers are processed and this procedure completes abruptly with that same exception. Otherwise, continue with step 5.
5. Execute the rest of the body of this constructor. If that execution completes abruptly, then this procedure completes abruptly for the same reason. Otherwise, this procedure completes normally.
- JLS中给出的Java类对象初始化顺序
- Java中对象的初始化顺序
- JAVA中子类与父类对象的初始化顺序
- java中对象初始化顺序
- Java中对象初始化顺序
- Java中对象初始化顺序
- Java中对象初始化顺序
- java类与对象的初始化顺序
- Java类及对象初始化的顺序
- Java类和对象的初始化顺序
- Java类与对象的初始化顺序
- Java类和对象的初始化顺序
- java类对象的初始化顺序
- java对象的初始化顺序
- java对象的初始化顺序
- java对象的初始化顺序
- JAVA对象的初始化顺序
- java对象的初始化顺序
- 【Android 开发】:数据存储之 SQLite 数据库操作(一)
- [问题解决]delphi dpk编译 Error: E2161 RLINK32: Unsupported 16bit resource in file xxx 问题解决
- 再见大学
- 关于Ubuntu12.04 安装JAVA7时需要安装的更新命令
- HDU1116-欧拉回路
- JLS中给出的Java类对象初始化顺序
- C# GDI+编程(三)
- 旋转的Button
- TNS-12542: TNS:address already in use 问题
- C#控制台冒泡排序 和百钱百鸡
- SQL Server 2008更改表“不允许保存更改”
- python学习七:正则表达式、多线程初探
- 几点iOS开发技巧
- 合格Java程序员应该掌握的东西