java integer long 转换_long(Long)与int(Integer)之间的转换
![作者头像](https://developer.qcloudimg.com/http-save/10011/5eef79a6a73684fac572184b7b0fa2c9.jpg)
大家好,又见面了,我是你们的朋友全栈君。
1.将long型转化为int型,这里的long型是基础类型:
long a = 10; int b = (int)a;
2.将Long型转换为int 型的,这里的Long型是包装类型:
Long a = 10; int b=a.intValue();
3.将Long型转换为 Integer 型的,这里的Long型是包装类型:
Long a = 10;; Integer b=a.intValue();
4.将int型转化为long型,这里的int型是基础类型:
int a = 10;long b = (int)a;
5.将Integer型转化为long型,这里的Integer型是包装类型:
int a = 10;Long b = a.longValue();
6.将Long型转化为Integer型,这里的Integer型是包装类型:
Long a = 10; Integer b=a.longValue();
总结:这里的转化就是要注意Java的八种基础数据类型以及八种包装数据类型的区别
基本类型和封装类的转换
Int转Integer: Integer integer = new Integer(int);
Integer转int: int i = integer.intValue();
Double转double: double b = Double.doubleValue();
Float转float: float c = Float.floatValue();
Java语言是一种强类型的语言。强类型的语言有以下
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/135019.html原文链接:https://javaforall.cn
社区
活动
资源
关于
腾讯云开发者
扫码关注腾讯云开发者
领取腾讯云代金券
热门产品
热门推荐
更多推荐
Copyright © 2013 - 2024 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号: 粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2024 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有