Jana 4.表达式

表达式


算术运算符

算术运算符 名称
+ 加法
- 减法
* 乘法
/ 除法
% 求余
++ 自增
-- 自减

其中,++ 和 -- 既可以出现在操作数的左边,也可以出现在右边,但结果是不同的。

int   a=++1;     a的结果为2            int  b=--1;    b的结果为0

int   a=1++;     a 的结果为1           int  b=1--;    b的结果为1


逻辑运算符

逻辑运算符

名称
&&
||

1、 与:所有条件都正确,才正确

2、 或:只要有一个条件正确就正确

3、 非:如果同意,非运算以后,就是不同意


数据类型转换

操作数1类型

操作数2类型

转换后的类型

扫描二维码关注公众号,回复: 6200278 查看本文章

byte、short、char

int

int

byte、short、char、int

long

long

byte、short、char、int、long

float

float

byte、short、char、int、long、float

double

double


运算符的优先级

优先级

运算符

1 ()
2 ! +(正) -(负) ++ --
3 */%
4 +(加) -(减)
5 < <= => >
6 == !=
7 ^
8 &&
9 ||
10 ?:
11 = += -= *= /= %=

猜你喜欢

转载自www.cnblogs.com/H97042/p/10848035.html
今日推荐