Integer自动装箱和拆箱
2024-09-05 22:15:13
Integer a=3; => Integer a=Integer.valueOf(3);
/**
*@description: 自动装箱和拆箱
*@auther: yangsj
*@created: 2019/4/2 15:48
*/
@Test
public void Test7(){
//自动装箱:
Integer num = 12;
//自动拆箱:
System.out.println(num + 12);//24
//基本数据类型的对象缓存:
// -128~127 输出true
// 超过该范围,输出false
Integer num1 = 12;
Integer num2 = 12;
System.out.println(num1 == num2);//true Integer num3 = 129;
Integer num4 = 129;
System.out.println(num3 == num4);//false //手动装箱
Integer num5 = Integer.valueOf(12);
Integer num6 = Integer.valueOf(12);
System.out.println(num5 == num6);//true Integer num7 = Integer.valueOf(128);
Integer num8 = Integer.valueOf(128);
System.out.println(num7 == num8);//false Integer num9 = new Integer(12);
Integer num10 = new Integer(12);
System.out.println(num9 == num10);//false }
最新文章
- 使用 SecurityManager 和 Policy File 管理 Java 程序的权限
- PHP正则表达式详解(二)
- peersim中BT网络核心代码解析
- 测试RAC的功能
- bzoj 1503 splay
- Powershell学习之道-文件夹共享及磁盘映射
- 玩转渗透神器Kali:Kali Linux作为主系统使用的正确姿势TIPS
- jquery.css 最简单的用法
- mysql的乱码问题
- 用php逐行读取文件
- grep、sed、awk、perl、js、vim等对正则表达式的支持的差别
- 【工作笔记一】【转】Visual Studio 2012常用快捷键总结
- Shell脚本中让进程休眠的方法(sleep用法)
- [Linux] PHP程序员玩转Linux系列-使用supervisor实现守护进程
- Lucene41PostingWriter源代码分析
- MySQL学习1 - 基本mysql语句
- web测试注意点
- linux 命令 — 文件相关
- golang使用redis
- 使用KeePass管理两步验证
热门文章
- Linux 系统下的7个运行级别
- Samba服务问答
- 简历内容-resume
- Greg and Array CodeForces 296C 差分数组
- A*(A_star)搜索总结
- django 中 slice 和 truncatewords 不同用法???
- win7 开启 telnet 服务
- 通过离线安装包解决了 from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: /usr/local/python36/lib/python3.6/site-packages/cryptography-2.2.2-py3.6-linux-x86_64.egg/cryptography/hazmat/binding
- MySQL第五天——日志
- 基于cdn方式的vue+element-ui的单页面架构