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