> For the complete documentation index, see [llms.txt](https://298073941.gitbook.io/memo/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://298073941.gitbook.io/memo/2020-05/java-ji-chu-1/shu-ju-zhuan-huan.md).

# 数据转换

java存在多种数值类型，所以会涉及数据转换

### 隐式转换

由小变大

byte、char、short->int->long->float->dubbo 自动提升

![](https://1306521860-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M63RWjY80LRidqkeQ5N%2F-M6DT5VGkvwjLn-Ypf0l%2F-M6DUauP4hBG1ravgyIj%2Fimage.png?alt=media\&token=c87b145d-30de-4a19-939c-6ef206ce15ed)

### 显示强转

数据可能会溢出

![](https://1306521860-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M63RWjY80LRidqkeQ5N%2F-M6DT5VGkvwjLn-Ypf0l%2F-M6DUtetdQUvO-_ZdnRi%2Fimage.png?alt=media\&token=8091b694-9c07-45f0-9fa3-5c58f2d75895)

### 数据装包和拆包

java 基本类型有个缺点就是无法为空，所以在平时程序运行时候可能会使用其他的类型来代替，如Integer对象来代替int

Integer在碰到+-的时候会自动拆解成int类型,可能会发生空指针异常

接口调用入参含有Integer，可以传递int类型，会自动包装成Integer
