posted 23 years ago
public class loap
{
public static void main(String[]args)
{
int x=4;
boolean b1,b2,b3,b4;
b1=b2=b3=b4=true;
x=(b1|b2 & b3^b4)?x++:--x;
System.out.println(x);
}
}
Hi Nitin,
The order of operator precedence is as follows:
& first, then ^, finally |
Thus b2 & b3 will yield true. A ^ (xor) of that result with b4 will yield false. Finally b1 | with false will yield true. And that is why you did not get the answer of 3.
Regards,
Lam