基本数据类型之间的转换分为隐式数据类型转换和显式数据类型转换,隐式数据类型转换也叫自动类型转换,是指由数据类型小的类型转换为数据类型大的类型,显式数据类型转换也叫强制类型转换,是指由数据类型大的类型转换为数据类型小的类型。
大家由float、long转换为int需要使用显示类型转换。float转换为int
1、inti=(int)f1;或者inti=(Float.valueOf(f1)).intValue();
2、long转换为int
longl1=1;
inti1=(int)l1;或者inti1=newLong(i1).intValue()。