java数据类型
1、数据类型
byte char short int long float double boolean
1 2 2 4 8 4 8 字节(*8bit) 1bit
long 后加L或l long a=123l;
float 后加F或f float b=12.3f;
String a="baichuanyang:"
a=a + 22 -> baichuanyang:22 //连接符,可把任意类型转换成字符串连接
//当出现加号,看加号左右数据类型,有String 作为连接符直接连接,
//多个+后面出现的+全作为连接符相连,无的话作为int型相加
//整数默认为int 型 小数默认为float型
//byte char short 做运算时,结果为int型
char c ='a';//97
System.out.println(c+c);//194
int num =10;
String str ="hello";
System.out.println(c+num+str); //107hello
System.out.println(c+str+num); //ahello10
System.out.println(c+(num+str));//a1ohello

浙公网安备 33010602011771号