关键字与运算符
Java 关键字
| abstract | assert | boolean | break | byte |
| case | catch | char | class | const |
| continue | default | do | double | else |
| enum | extends | final | finally | float |
| for | goto | if | implements | import |
| instanceof | int | interface | long | native |
| new | package | private | protected | public |
| return | short | static | strictfp | super |
| switch | synchronized | this | throw | throws |
| transient | try | void | volatile | while |
逻辑 / 位运算符优先级
! > && > ||~ > & > |
运算符优先级
当两个运算符的优先级相同,则按照结合性的顺序求值
| level | operator | description | Associativity |
|---|---|---|---|
| 16 | [] . () | 访问数组元素、对象成员、括号 | left to right |
| 15 | ++ -- | 后置自增自减 | not associative |
| 14 | ++ -- + - ! ~ | 前置自增自减、一元加减、一元位取反、一元逻辑非 | not associative |
| 13 | () new | 转换、创建对象 | right to left |
| 12 | * / % | 乘除法 | left to right |
| 11 | + - + | 加减法、字符串拼接 | left to right |
| 10 | << >> >>> | 移位运算符 | left to right |
| 9 | < <= > >= instanceof | 关系运算符 | not associative |
| 8 | == != | 判断等于 | left to right |
| 7 | & | 位与 | left to right |
| 6 | ^ | 位异或 | left to right |
| 5 | | | 位或 | left to right |
| 4 | && | 逻辑与 | left to right |
| 3 | || | 逻辑或 | left to right |
| 2 | ?: | 三元运算符 | right to left |
| 1 | = += -= *= /= %= &= ^= |= <<= >>= >>>= | 赋值 | right to left |
德摩根定律
!(A && B) = !A || !B!(A || B) = !A && !B
!(A && B && C) = !A || !B || !C!(A || B || C) = !A && !B && !C
左移右移
<<: 左移,右边补零>>: 右移,左边补最高位>>>: 右移,左边补零
不懂的地方
L6 PPT P21,P22