/*
1, 数据类型中的整数型
数据类型 占用空间 默认值 取值范围
byte 1 0 -127~128
short 2 0 -32768~32767
int 4 0 -214783648~2147483647
long 8 0L
2, JAVA中的数据类型字面值的三种表示方式:
1,十进制
2,八进制 以0开头
3十六进制 以0x开头
*/
public class Davl6{
public static void main(String[]args){
int a=10;
int b= 010;//8进制
int c=0x10;//十六进制
System.out.println(a+b+c);//系统输出34,系统默认是10进制
//123这个数字型字面值是int型
int i=123;
long x=456;
//long类型是大容量
//小容量可以自动转换成大容量,称为自动类型转换
// 声明long类型是时必须要加L
}
/*
java中的整数型
byte
short
int
long
*/
public class Davl7{
public static void main(String[]args){
long c=100L;
//int b=c;//编译错误,大容量不能直接转换成小容量
//强制类型转换 需要”强制类型转换符“
//int c=10000000000L;
//int b=(int)c;
//强制转换符需要谨慎使用,因为有精度损失
int b=(int)c;
//强转原理:
//原始数据:000000 000000 000000 000000 000000 00000
//转换后的数据: 000000 000000 00000
//将原始数据的二进制砍半
System.out.println(b);
}}