java integer long 转换_long(Long)与int(Integer)之间的转换

java integer long 转换_long(Long)与int(Integer)之间的转换1.将long型转化为int型,这里的long型是基础类型:longa=10;intb=(int)a;2.将Long型转换为int型的,这里的Long型是包装类型:Longa=10;intb=a.intValue();3.将Long型转换为Integer型的,这里的Long型是包装类型:Longa=10;;Integerb=a.intValue(…

大家好,又见面了,我是你们的朋友全栈君。

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.net/135019.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号