Java八大基本類型支持的運算符

來源:think in java 第三章 3.1.16運算符總結
運算符英文解釋:
Arithmetic operators:算術運算符
Relational and logical: 關係和邏輯運算符
Bitwise operators: 位運算符
Compound assignment:複合賦值

Casting:類型轉換

boolean類型之間
Arithmetic operators: 不支持
Relational and logical: == ,!=,>=,<=,!,&&,||
Bitwise operators: & , | , ^
Compound assignment: &=,|=,^=

Casting:不支持

char類型之間
Arithmetic operators: *,/,% ,+,- ,++ ,–
Relational and logical: >,>=,<,<=,==,!=
Bitwise operators: ~,&,|,^,>>,<<,>>>
Compound assignment: +=,-=,*=,/=,%=,&=,|=,^=,<<=,>>=,>>>=

Casting:支持轉換的類型:除了boolean類型,都支持轉換。

byte類型之間
Arithmetic operators: 同上
Relational and logical: 同上
Bitwise operators:同上
Compound assignment:同上

Casting:同上

short類型之間
Arithmetic operators: 同上
Relational and logical: 同上
Bitwise operators:同上
Compound assignment:同上

Casting:同上

int類型之間
Arithmetic operators: 同上
Relational and logical: 同上
Bitwise operators:同上
Compound assignment:同上

Casting:同上

long類型之間
Arithmetic operators: 同上
Relational and logical: 同上
Bitwise operators:同上
Compound assignment:同上

Casting:同上

float類型之間
Arithmetic operators: 同上
Relational and logical: 同上
Bitwise operators:不支持
Compound assignment:僅支持+,-,*,/,%

Casting:同上

duble類型之間
Arithmetic operators: 同上
Relational and logical: 同上
Bitwise operators:不支持
Compound assignment:僅支持+,-,*,/,%
Casting:同上

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章