Ps:字符串不属于基本数据类型,它是类!
扫描二维码关注公众号,回复:
9973915 查看本文章
基本数据类型变量的存储(按照作用范围分为)
- 类级
- 对象实例级
- 方法级
- 块级
运算中的数据类型
// 运算中的数据类型:
int a=Integer.MAX_VALUE, b=Integer.MAX_VALUE;
long rs1=(long)a+(long)b; // 运算中的数据类型:long
long rs2=a+(long)b; // 运算中的数据类型:long
long rs3=(long)(a+b); // 运算中的数据类型:int
long rs4=a+b; // 运算中的数据类型:int
System.out.println(rs1);
System.out.println(rs2);
System.out.println(rs3);
System.out.println(rs4);
short s1=30000;
short s2=10000;
short s3=(short)(s1+s2); // s1 和 s2 先转换成 int 类型在进行运算