• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bitwsie and short-circuit logical operators

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I was curious if bitwise and short-circuit logical operators have an order of procedence. For example (which came from an scjp book):



or another



Thanks in advance
[ February 09, 2006: Message edited by: Jerret Halter ]
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java's Order Of Prescendence (taken from Teach Yourself Java 2 in 21 Days, pages 84-85):

. [] ()
++ -- ! ~ instanceof
new (cast)...
* / %
+ -
<< >> >>>
< > <= >=
== !=
&
^
|
&&
||
?:
= += -= *= /= %= ^=
&= |= <<= >>= >>>=

The higher on the list, the sooner it happens.
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's one thing to watch out when using the | and & operators. They will evaluate your entire conditions, so be careful if you may hit a NullPointerException in the testing conditions.

Operators && and || are generally faster as they won't execute the entire set of conditions.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic