-
byte
byte占用一个字节,-128~127
-
short
short占用2个字节,-36728~36726
-
int
int占用4个字节,范围很大21亿多
-
long
long占用8个字节,范围更大
-
float
float占用4个字节
-
double
double占用8个字节
字符类型就一个char,占用2个字节,这里要切记String不是基本类型,很多人初学者会以为String是基本类型里面的字符类型。
Booleanboolean占用一位字节,它的值只有false,true
idea代码演示public class text {
public static void main(String[] args) { //psvm是主方法的快捷键
byte a=1;
short b=2; //byte和short注意不要超过它们的范围了
int c=3;
long d=4L; //使用long是,需要在数据后面跟一个大写的L
float s=1.111F ;
double r=3.1415926535;
char tt='q';
//Boolean flag=true;
//Boolena flag1=false;
System.out.println(a); //sout是输出的快捷键
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(s);
System.out.println(r);
System.out.println(tt);
}
}



