/*
数据类型:
基本数据类型 : 4类8种
整型
字节型 byte 1byte 8bit [-128,127]
短整型 short 2byte 16bit [-32768,32767]
*****整型 int 4byte 32bit +-21亿
长整型 long 8byte 64bit 非常大
在java中 整数字面常量值默认的数据类型为int
如果表示long类型的数据,需要在数据的后面添加一个L/l,建议大写
浮点型
单精度 float 4个字节 表示小数点后7位左右
*****双进度 double 8个字节 表示小数点后16位左右
在java中 小数字面常量值默认的数据类型为dobule
浮点类型计算都不精确
想要为float类型赋值,需要在数据的后面添加F/f
字符型
char 字符型 2byte
字符型的表现形式:
0~65535之间的整数表示一个字符
''中包含单个字符,有且仅有一个字符
布尔型
boolean 布尔类型 1bit true/false
引用数据类型 :
类 接口 数组[]
*/
public class DataType09{
public static void main(String[] args){
//byte
byte b1 = 127;
System.out.println(b1);
//short
short sh1 = 10000;
System.out.println(sh1);
//int
int salary = 10000000;
System.out.println(salary);
//long
long l1 = 10000000011L;
System.out.println(l1);
//double
double d1 = 0.12345678912;
System.out.println(d1);
//float
float f1 = 0.12345678912f;
System.out.println(f1);
//char
char ch1 = ' ';
char ch2 = 'a';
char ch3 = '1';
char ch4 = '中';
char ch5 = ',';
char ch6 = 97;
System.out.println(ch6);
//boolean
boolean True = false;
boolean flag = True;
System.out.println(flag);
}
}
数据类型
最新推荐文章于 2024-07-15 22:27:18 发布