diff --git a/day02/src/com/inmind/Demo02.java b/day02/src/com/inmind/Demo02.java new file mode 100644 index 0000000..2e9b7b9 --- /dev/null +++ b/day02/src/com/inmind/Demo02.java @@ -0,0 +1,23 @@ +package com.inmind; +/* +自动转换:将取值范围小的类型自动提升为取值范围大的类型 。 +数据类型转换---自动转换中转换顺序 + +转换顺序:byte、short、char---->int---->long---->float---->double + +强调:byte、short、char 在运算都是直接提升至int +*/ +public class Demo02 { + public static void main(String[] args) { + byte b1 = 127; + short s = b1; + int i = b1+s; + long l = i + s; + float f = l+i; + double d = f+l; + System.out.println("---------------------------------"); + byte t1 = 10; + byte t2 = 20; + //short s1 = t1+t2;//注意:byte、short、char 在运算都是直接提升至int + } +}