The explaination says : Compilation error because Here ternary operator & augmented form of assertion are used in a wrong way. Syntex of ternary operator is <Boolean exp>?<msg>:<msg> In augmented form of assertion, syntax is, assert <Boolean expression> : <msg expression> If we write it as assert (a > 0) ? <Boolean exp> : <Boolean exp>; then it will compile .
I am not clear with the bold part.For eg if we use it as follows: int a=0; assert (a > 0) ? true : false;
what is the above code doing ??
SCJP6:80%, OCWCD 88 %
posted 8 years ago
assert (a > 0) ? true : false; is just a roundabout way of saying: assert a>0;
All code in my posts, unless a source is explicitly mentioned, is my own.