• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

order of precedence

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class jd{
public static void main(String a[]){
int x=0;
booloan b1=b2=b3=b4=true;
x=(b1 | b2 & b3 ^ b4) ? x++ : --x;
System.out.println(x);
}
}
please tell me where to begin while solving these problems
thanks in advance
payal
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Payal,
The precedence order is:
Bitwise/boolean AND
Bitwise/boolean XOR
Bitwise/boolean OR
So your example would be like:
x = (b1 | ((b2 & b3) ^ b4))
First: b2 & b3 = f1
Second: f1 ^ b4 = f2
Third: b1 | f2
Regards,
Manfred.
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic