700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java integer long 转换_long(Long)与int(Integer)之间的转换

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

时间:2022-04-23 12:23:17

相关推荐

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

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语言是一种强类型的语言。强类型的语言有以下

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。