Java 语言整型常量的四种表示形式
十进制整数,如:99, -500, 0
八进制整数,要求以 0 开头,如:015
十六进制数,要求 0x 或 0X 开头,如:0x15
二进制数,要求0b或0B开头,如:0b01110011
public class TestPrimitiveDataType {
public static void main(String[] args) {
int a = 15;
int b = 015; //8进制
int c = 0x15; //16进制
int d = 0b1101; //二进制
System.out.println(b);
System.out.println(c);
System.out.println(d);
byte age = 30;
short salary = 30000;
int population = 2000000000; //整形变量默认是int类型
long globalPopulation = 7400000000L; //后面加L/l表明这是一个long类型的常量
}
}