Can someone please tell me if my guess below is correct?

boolean b1, b2, b3, b4;

b1 = b2 = b3 = b4 = true;

int x = (b1 | b2 & b3 ^ b4)? x++: --x;

System.out.println("Result: " + x);

**Result: 0** Since (b1 | b2 & b3 ^ b4) evaulates to

**true**, we postfix increment x, then we prefix decrement x --> which gets us back to

x = 0.

BUT if (b1 | b2 & b3 ^ b4) were to evaluate to

**false**, we would SKIP the x++ and jump to to what's beyond the colon: (--x)? If so, then

x = -1.

So:

- We only execute what's between ? and : (in this case, x++) if the statement inside the parentheses is TRUE?

- But we execute the code AFTER the : (in this case, --x) no matter what?

In other words:

x = (

test)? x++: --x

if

**test is true** do everything after the question mark?

if

**test is false** do everything after the colon?

Thanks! I know this was a long post.

Susan

[This message has been edited by Susan Delph (edited May 01, 2001).]