Skip to content

Commit

Permalink
java基本类型及方法剖析
Browse files Browse the repository at this point in the history
  • Loading branch information
weijieming committed Jun 10, 2019
1 parent f440eba commit 3754101
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion doc/basetype.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,18 @@ bString = 2.3
- 一个点有多个出度 —— 分支结构
- 形成了环 —— 循环结构


## 拆箱与装箱

Java 中为每一种基本数据类型提供了相应的包装类,提供一种机制,使得基本数据类型可以与引用类型互相转换。

> 基本数据类型与包装类的转换被称为装箱和拆箱
装箱(boxing)是将值类型转换为引用类型。例如:int 转 Integer
装箱过程是通过调用包装类的 valueOf 方法实现的。

拆箱(unboxing)是将引用类型转换为值类型。例如:Integer 转 int
拆箱过程是通过调用包装类的 xxxValue 方法实现的。(xxx 代表对应的基本数据类型)。

> Java 对于自动装箱和拆箱的设计,依赖于享元设计模式。享元模式尝试重用现有的同类对象,如果未找到匹配的对象,则创建新对象。
## 使用规范及注意事项

0 comments on commit 3754101

Please sign in to comment.