File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes regarding preceedence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "regarding preceedence" Watch "regarding preceedence" New topic
Author

regarding preceedence

shreya prabhu
Ranch Hand

Joined: Feb 10, 2007
Posts: 31
b1=true,b2=true,b3=false
b3&=b1|b2->this evaluates to false
b3=b3&b1|b2->this evaluates to true
why does it give different result?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Originally posted by archana prabhu:
b1=true,b2=true,b3=false
b3&=b1|b2->this evaluates to false
b3=b3&b1|b2->this evaluates to true
why does it give different result?


| has a higher precedence than &=

so b3 &= b1|b2 is the same as b3 &= (b1|b2) which is b3 &= true which is false since b3 is false.

& has a higher precedence than |

so b3 = b3 & b1 | b2 is the same as b3 = (b3 & b1) | b2 = false | true = true.
 
wood burning stoves
 
subject: regarding preceedence