---
title: "你真的理解java中的自动拆箱和自动装箱以及类型转换吗？"
author: "FireZHFox"
date: "2015-02-10T11:10:28Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2015-02-10T15:18:23Z"
id: 2184791
url: "https://firezhfox.iteye.com/blog/2184791"
---

```
public class Test {

    public static void main(String[] args) {
        Integer a=1;
        Integer b=2;
        Integer c=3;
        Integer d=3;
        
        Integer e=321;
        Integer f=321;
        
        Long g=3L;
        
        System.out.println(c==d);
        System.out.println(e==f);
        System.out.println(c==(a+b));
        System.out.println(c.equals(a+b));
        System.out.println(g==(a+b));
        System.out.println(g.equals(a+b));
    }
}
```

  

```
包装类的“==”运算在不遇到算术运算的情况下不会自动拆箱，以及它们的equals方法不处理数据转型
```