packagecom.ith.type;publicclass typedemo1 {publicstaticvoidmain(String[] args){byte a=20;int b = a;//自动类型转换System.out.println(a);System.out.println(b);int age =18;double db = age;//int->doubleSystem.out.println(db);char ch ='a';//char->intint code = ch;System.out.println(ch);}}
1.2 表达式中自动类型转换
packagecom.ith.type;publicclass typedemo2 {publicstaticvoidmain(String[] args){byte a =10;int b =20;double c =10;double re = a + b + c;System.out.println(re);double re2 = a + b -2.3;System.out.println(re2);}}
packagecom.ith.operator;publicclass operatortest2 {publicstaticvoidmain(String[] args){int data =346;//个位int ge = data%10;System.out.println(ge);//十位int shi = data/10%10;System.out.println(shi);//百位int bai = data/100;System.out.println(bai);}}
2.3 ’+‘ 做连接符
packagecom.ith.operator;publicclass operatordemo3 {publicstaticvoidmain(String[] args){int a =5;System.out.println("abc"+ a);//abd5System.out.println("abc"+'a');//abcaSystem.out.println(a +'a');//102System.out.println("hh"+5+'a');//hh5aSystem.out.println(5+'a'+"hh");//102hh}}