• Post Reply Bookmark Topic Watch Topic
  • New Topic

Boolean expression  RSS feed

 
Robert Willems
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
we are reading the excellent book Java2 Study guide for 310-035 but we have a little question about a boolean expression that is in there.
it says that with the following statement:

when y = 5, x = 2 and doStuff() always returns true, it will print nothing.
However in our mind it should evaluate to [BOLD]true[/BOLD]!
It says the runtime compiler would execute it like

Why??? Are there rules for the precedence of operators? Do the shortcircuit operator have a lower precedence than the boolean operators?
Have help would be appreciated.
Regards,
Robert Willems
 
aminur rashid
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
bitwise inclusive OR '| '
is higher in precedence.
Check this
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html
Spec
 
Robert Willems
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! that solves the whole problem ;-)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!