类的创建过程(摘抄与java编程思想)
来源:互联网 发布:假人交友app源码 编辑:程序博客网 时间:2024/06/06 14:01
早上又起来看了下java编程思想(英语和java兼得),关于类的创建过程,之前也没有在写程序的时候,也就从来没有去想过到底是怎么的一回事,反正是new一个!然后就去用!今天在书里看到这么一段的内容摘抄下来
1.Even though it doesn't explicitly use the static keyword,the constructor is actually a static method.So the first time an object of type Dog is created,or the first time a static method or static field of class Dog is ccessed,the java interpreter must locate Dog.clss,which it does by searching through the classpath.
(
尽管它没有明确地使用static关键词,构造函数实际上是一个static方法。所以当第一次这个Dog的对象被创建或者第一次static方法或静态域被访问时,java将会通过classpath去加载Dog.class
)
2.As Dog.class is loaded,all of its static initializers are run.Thus,static Initialization takes
place only once,as the Class object is loaded for the first time.
(
当Dog.class被加载时,所有的静态内容进行初始化,初始化的过程只发生在类被第一次加载的时候
)
3.When you create a new Dag(),the construction process for Dog object first allocates enough storage for a Dog object on the heap.
(
当你创建一个Dog时,在个过程中会为这个对象在堆中分配足够的存储空间
)
4.This storage is wiped to zero,automatically setting all the primitives in that Dog object to their default values and the references to null.
(
而这块区域中的内容将被清零,自动的为基本数据类型赋予默认值,为引用赋予null
)
5.Any initialization that occur at the point of field definition are executed.
(
然后执行对这些成员域(属性)的初始化/*4和5不是相同的过程,首先所有的属性都会先被赋予默认值,然后再根据程序员的意图进行初始化*/
)
6.Construtors are executed.As you shall see int the Reusing Classes chapter,this might actually involve a fair amount of activity,expecially when inheritance is involved.
(执行构造函数)
1.Even though it doesn't explicitly use the static keyword,the constructor is actually a static method.So the first time an object of type Dog is created,or the first time a static method or static field of class Dog is ccessed,the java interpreter must locate Dog.clss,which it does by searching through the classpath.
(
尽管它没有明确地使用static关键词,构造函数实际上是一个static方法。所以当第一次这个Dog的对象被创建或者第一次static方法或静态域被访问时,java将会通过classpath去加载Dog.class
)
2.As Dog.class is loaded,all of its static initializers are run.Thus,static Initialization takes
place only once,as the Class object is loaded for the first time.
(
当Dog.class被加载时,所有的静态内容进行初始化,初始化的过程只发生在类被第一次加载的时候
)
3.When you create a new Dag(),the construction process for Dog object first allocates enough storage for a Dog object on the heap.
(
当你创建一个Dog时,在个过程中会为这个对象在堆中分配足够的存储空间
)
4.This storage is wiped to zero,automatically setting all the primitives in that Dog object to their default values and the references to null.
(
而这块区域中的内容将被清零,自动的为基本数据类型赋予默认值,为引用赋予null
)
5.Any initialization that occur at the point of field definition are executed.
(
然后执行对这些成员域(属性)的初始化/*4和5不是相同的过程,首先所有的属性都会先被赋予默认值,然后再根据程序员的意图进行初始化*/
)
6.Construtors are executed.As you shall see int the Reusing Classes chapter,this might actually involve a fair amount of activity,expecially when inheritance is involved.
(执行构造函数)
- 类的创建过程(摘抄与java编程思想)
- java对象的创建过程(摘自《java编程思想》)
- 对象的创建过程(来自《java编程思想》)
- 《Java编程思想》之对象的创建、使用、生命期(简单比较java与C++的不同之处)
- 《冒号课堂:编程范式与OOP思想》摘抄
- 枚举——摘抄自《java编程思想》
- java编程思想学习笔记(一)——java类与c++类的区别
- C++--CSplitterWnd::CreateView创建CListView创建过程的调试摘抄
- C++--CSplitterWnd::CreateView创建CListView创建过程的调试摘抄
- 面向对象与面向过程的编程思想比较
- C++编程思想学习-对象的创建与使用
- C++编程思想 第二章 对象的创建与使用
- 面向过程的编程思想
- java调用存储过程(摘抄)
- 【java编程思想--学习笔记(三)】访问控制-接口实现与类的访问权限
- Java 编程思想12.4-创建自定义的异常
- 26.JAVA编程思想——创建自己的违例
- Java编程指南摘抄
- 【读书笔记】松本行弘的程序世界
- android之Display.getRotation()_传感器控制屏幕旋转
- Linux下安装jdk报Permission denied以及chmod详解
- Wikioi 天梯 数的计算(1011)
- [0]Android框架揭秘-概论
- 类的创建过程(摘抄与java编程思想)
- JS代码的window.location属性详解
- 关于typedef的用法总结
- 使用远程桌面 实现本机与远程服务器的文件拖放
- 自己动手写类似酷狗播放器(3)_Slider控件使用
- Shared SQL area && Private SQL area
- Eclipse用法和技巧二十三:查看JDK源码
- Wikioi 天梯 Fibonacci数列 3(1978)
- ORA-00401: the value for parameter compatible is not supported by this release