类型转换
public class Demo3 {
public static void main ( String[ ] args) {
int i = 128 ;
byte b = ( byte ) i;
double c = i;
System. out. println ( i) ;
System. out. println ( b) ;
System. out. println ( c) ;
System. out. println ( "=======================================" ) ;
char d = 'a' ;
int e = d + 1 ;
System. out. println ( e) ;
System. out. println ( ( char ) d ) ;
}
}
public class Demo4 {
public static void main ( String[ ] args) {
int money = 1 _000_000_000;
int years = 20 ;
int total = money* years;
long total2 = money* years;
long total3 = money* ( ( long ) years) ;
System. out. println ( total3) ;
}
}
基本运算符
package operater;
public class Demo1 {
public static void main ( String[ ] args) {
int a = 10 ;
char b = 20 ;
short c = 30 ;
long d = 405485947239 L;
System. out. println ( a+ b) ;
System. out. println ( b- c) ;
System. out. println ( a* b) ;
System. out. println ( a/ ( double ) d) ;
System. out. println ( b% a) ;
System. out. println ( a> b) ;
System. out. println ( a< b) ;
System. out. println ( a== c) ;
System. out. println ( a!= d) ;
}
}