This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Operator precedence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Operator precedence" Watch "Operator precedence" New topic

Operator precedence

Divya Eknath

Joined: Jul 27, 2006
Posts: 9
Can anybody please tell me the precedence of bitwise/ligical operators:&,^ and |?
In some books its given as & ^ |, while in others it is & | ^.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
&,^, |

Expressions, Statements, and Blocks
Simeon Cherniy

Joined: Jul 26, 2006
Posts: 21
The order is: & ^ |
x^y = (x | !y) & (!x | y)
That's why the priority of XOR(^) is higher

5-year Student of <br />Moscow Institute of Physics and Technology.
Simeon Cherniy

Joined: Jul 26, 2006
Posts: 21
x^y = (x | y) & (!x | !y)
I agree. Here's the link:
subject: Operator precedence
Similar Threads
< operator
code behaving strangely
From deepak's mock
Multiple Assignments from Khalid's book