四种整型的类型:
byte:一个字节,8位,2^8=256
short:两个字节,2^16
int:四个字节,2^32
long:八个字节,2^64
整型常量的四种表示形式
整型常数默认为int型,声明long型常量可以后加‘ l ’或‘ L ’ 。
- 十进制整数,如:99, -500, 0
 - 八进制整数,要求以 0 开头,如:015
 - 十六进制数,要求 0x 或 0X 开头,如:0x15
 - 二进制数,要求0b或0B开头,如:0b01110011
 
For Example_01:
package com.Ponfey;
/**
 * 测试基本数据类型
 * Created by xiaoshuai.zhu on 2020-09-21 11:20
 */
public class TestPrimitiveDataType {
    public static void main(String[] args) {
        //测试整型变量
        int a =15; // 15是一个整型的常量,a就是整型的变量
        int b = 015; //八进制,逢8进1,相当于8+5=13
        int c = 0x15; //十六进制,逢16进1,16+5=21
        int d = 0b1101; // 二进制,
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        byte age = 200; //声明200,超过了age的定义,因为是byte,-128~127,写23是没有问题的
        short salary = 100000; //同样,short写1w可以,写10w就超出了
        int population = 2000000000; //整型常量默认是int类型
        long globalPopulation = 7400000000L; //超出int类型范围,需要在后面添加L,表示长整型的常量,L的大小写都是可以的,小写的容易和数字1混淆
    }
}
	




