• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Bear Bibeault
  • paul wheaton
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Mikalai Zaikin
  • Piet Souris
Bartenders:

Boolean expression

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! that solves the whole problem ;-)
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic