初学java1 数据类型

java数据类型

分为8种

整型

byte 8位
short 16位
int 32位
long 64位

显示范围

字符型

char 必需为单引号'' 且只能有一个字符

浮点型

float
double

布尔类型

boolean 只能为true false

还有一种字符串型

需要声明
String s="sadfas";

        byte byt = 22;   //8位 -127~128
	short s = 13124; //16位 -32768~32767
	int a = 1;       //32位 -21亿~21亿
	long b = 2;      //64位 19个0
	char c = 's';    //单引号 只能有一个字符
	float d = 1.324f;  //一般必须在之后加f
	double e =1.324;
	boolean f = true;   //虽然0和1代表true,false,但是不能用0 1赋值
	
	static String str = "dsfsd";  //String类型
posted @ 2019-11-11 18:32  iomc  阅读(209)  评论(0)    收藏  举报