Demo1
该章节主要学习强制转换以及一些精度问题
整数型:byte -128~127
-
short -32768~32767
-
int -2147483648~2147483648
-
long -2^83~2^83 -1
浮点型:
-
float -3.403E38~3.4003E38
-
double -1.798E308~1.798E308
字符型 char 表示一个字符,如(‘a’,‘A’,‘0’,‘家’)
布尔型 boolean 只有两个值true和false
public class Demo1 {
public static void main(String[] args) {
int money=10_0000_0000;
int years=20;
long account=money*years;
System.out.println("非强制转换"+account);
System.out.println("======================================================");
long account1=money*(long)years;
System.out.println(account1);
System.out.println("======================================================");
System.out.println("强制转换"+(long)money*years);
System.out.println("======================================================");
/*
* 强制转换 由高转低精度丢失
* */
long money1=10_0000_0000;
long years1=20;
long account2=money1*years1;
System.out.println("高转低"+(int)account2);
char a='大';
//看到26集
}
}