标识符:以字母、下划线、美元符号开始,有数字、字母、下划线、美元符号组成。
数据类型:
①基本数据类型:boolean(1)、byte(1)、char(2)、short(2)、int(4)、long(8)、float(4)、double(8)
②引用数据类型:String、Integer、ArrayList等
运算符:
①算术运算:+ - * / % ++ --
②关系运算:== != > >= < <=
③逻辑运算:&& || !
④位运算:& | ^(异或) ~(取反)
⑤移位运算:<< >>(带符号右移) >>>(无符号右移)
⑥赋值运算: = += -= *= /= %=
数据类型转换:
①自动数据类型转换
运算 |
运算结果的数据类型 |
double与任意类型运算 |
double类型 |
long与int、short、char、byte运算 |
long类型 |
int与short、char、byte运算 |
int类型 |
short与char、byte运算 |
short类型 |
char与byte运算 |
char运算 |
float与int、short、char、byte运算 |
float运算 |
float与long运算 |
float运算 |
②数据类型转换
double a = 0.15;
int b = (int)a;
运算符优先级:
优先级 |
运算符 |
1 |
() [] |
2 |
! +(正号) –(负号) ~ ++ –– |
3 |
* / % |
4 |
+(加号) –(减号) |
5 |
<< >> >>> |
6 |
< <= > >= instanceof |
7 |
== != |
8 |
& |
9 |
^ |
10 |
| |
11 |
&& |
12 |
|| |
13 |
?:(三元表达式) |
14 |
= += –= *= /= %= &= |= ^= ~= <<= >>= >>>= |