1.整形
public class IndentifierTest01{
public static void main(String[] args) { //byte一个字节 //short两个字节 //int 四个字节 //long 八个字节 //测试整形变量 int a=15; int b = 015;//以0开头是八进制 int c = 0x15;//以0x开头是十六进制 int d = 0b1101;//以0b开头是二进制 //以十进制输出 System.out.println(b); System.out.println(c); System.out.println(d); }
}
2.浮点型
public class IndentifierTest01{ public static void main(String[] args) { float a = 3.14f;//小数默认double类型,要加f double b = 6.28;//后面d加不加都可 //不要用浮点数直接进行比较,因为不精确 //比较的话用java.math包 } }