int和Integer的区别
来源:互联网 发布:cimatrone11编程教程 编辑:程序博客网 时间:2024/06/01 20:10
- 代码如下
public class Main { public static void main(String[] args) { //基本类型比较,只比较数值是否相等 int n1 = 47; int n2 = 47; System.out.println(n1 == n2); System.out.println("================="); //虽然数据类型是包装型的,但是jvm中存在常量池, // 这种定义变量的方式会保存到常量池,所以尽管 // 比较的是两个对象的内存地址,但是还是相等的 Integer n3 = 47; Integer n4 = 47; System.out.println(n3 == n4); System.out.println("================="); //使用new的方式,对象会保存到堆内存,所以肯定 // 是两个不同的对象,所以内存肯定不同 Integer n5 = new Integer(47); Integer n6 = new Integer(47); System.out.println(n5 == n6); }}
- 输出结果
true=================true=================false
阅读全文
0 0
- int 和 Integer 的区别
- int 和 Integer 的区别
- int和Integer的区别
- int和Integer的区别
- int 和 integer的区别
- Integer和int的区别
- Integer 和 int 的区别
- int和integer的区别
- int和Integer的区别
- int 和integer的区别
- int 和 Integer的区别
- int 和integer的区别
- int 和integer的区别
- Integer和Int的区别
- int 和integer的区别
- int 和integer的区别
- Int 和integer的区别
- int 和Integer的区别
- 花生壳+IIS部署外网项目
- 面试题4:替换空格
- HTTP、FTP状态码 汇总
- iOS-手把手教你如何写block
- retrofit 自定义请求参数加密 和自定义响应解密 带你走出那些坑
- int和Integer的区别
- 02_核心概念--08_现代工具箱中的拖放
- PHP session 跨子域问题总结
- IOS内购验证
- Qwidget剪贴板的使用
- PuTTY (4) SSH
- CentOS下配置完全分布Hadoop-2.6.0-cdh5.6.0(2)
- UML设计9种设计图
- Window和WindowManager(Android开发艺术探索学习笔记)