wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Have a question about operators 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 "Have a question about operators" Watch "Have a question about operators" New topic
Author

Have a question about operators

chang nanny
Greenhorn

Joined: Feb 15, 2004
Posts: 14
Hello,
class SSBool{

public static void main(String[] args){
boolean b1 = true;
boolean b2 = false;
boolean b3 = true;
if(b1 & b2 | b2 & b3 | b2){
System.out.println("ok");
}
if(b1 & b2 | b2 & b3 | b2 | b1){
System.out.println("dokey");
}
}
}
output is kdokey
Could someone tell why the reason is "okdokey"?
Thank you.
C. Magmanum
Ranch Hand

Joined: Apr 03, 2004
Posts: 35
the output is
dokey
compare the values from left to right and evaluate with each step, u might get a better grasp.
Lionel Orellana
Ranch Hand

Joined: Mar 19, 2004
Posts: 87
Originally posted by chang nanny:




& has higher precedence than |. So this is like saying

cheers
chang nanny
Greenhorn

Joined: Feb 15, 2004
Posts: 14
hello,
thank you.
 
 
subject: Have a question about operators