In Java, is a++ a postfix operator or an unary operator?

点点圈 提交于 2020-05-17 07:25:12

问题


In Java, is a++ a postfix operator or an unary operator? In the Operator Precedence from Oracle, it is separated. Reference


回答1:


It’s both. It’s a unary operator because it works solely on one term. If it’s x++ then it’s a postfix operator as it’s incremented after using the variable’s value. A prefix unary operator is ++x where it’s incremented before being used. Prefix operators have a higher precedence, but they’re both unary operators



来源:https://stackoverflow.com/questions/60014618/in-java-is-a-a-postfix-operator-or-an-unary-operator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!