一元操作员是否真的首先被执行?
我有关于优先事项的问题。 Java指出,这是解决操作员(从高到低)的优先事项:
- 后缀一单位OPARTORS XYZ ++,XYZ--
- fixunary opartors ++ xyz,-xyz
- TypeConversion / casting / casting / casting
- “* /%
- ”+ - + -
- <<<< >>
- < < => > =
- ==,!=
- &
- 独家
- |
- &&
- ||
- ?:
- =, +=, - =, *=, /=,%=
现在,如果您查看单一操作员,他们说:
在单一邮政邮局中,表达式之后将执行Unary。
这意味着,如果您有:
int a = 2;
int b = a++ * 3;
int b
将为6,则表达式之后仅获得+1。
在一元前固定中,Unary在表达式之前被执行:
int a = 2;
int b = ++a * 3;
int b
将为9。
我的问题是,这并不意味着后缀的单一操作员应该在第6号,前缀为1号?我看错了什么?
I have this question regarding priorities. Java states that this is the priority to work out operators (from high to low):
- postfix unary opartors xyz++, xyz--
- prefixunary opartors ++xyz, --xyz
- typeconversion/casting
- "* / %
- "+ -
- << >>
- < <= > >=
- ==, !=
- &
- exclusive
- |
- &&
- ||
- ?:
- =, +=, -=, *=, /=, %=
Now, if you look at unary operators, they state that:
In the unary postfixnotation , unary gets executed after the expression.
Meaning that if you have:
int a = 2;
int b = a++ * 3;
int b
will be 6, cause a only gets +1 after the expression.
in the unary prefixnotation, unary gets executed before the expression:
int a = 2;
int b = ++a * 3;
int b
will be 9.
My question is, doesnt this mean that postfix unary operators should be at number 6 and prefix at number 1? What am I seeing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在评估IS
a
之后,将应用一元运算符的“表达式”,而不是任何表达式可能是其中的一部分。The "expression" that the unary operator is applied after the evaluation of is
a
, not any expression it might be part of.