/*
隐式变换 byte,short,char -- long -- float -- double;
强制转换 目标数据类型 变量名 = (目标数据类型) (被转换的数据)
*/
public class TypeCast {
public static void main(String[] args) {
//定义两个变量
int a = 10;
byte b = 20;
int c = a + b;
System.out.println(c);
byte d = (byte) (a + b);
System.out.println(d);
}
}
隐式转换与强制转换
最新推荐文章于 2024-09-12 22:02:45 发布