Given that v.inStock() returns a boolean, why does this compile?
but this does not
[greg@localhost servlet]$ javac SomeProgram.java SomeProgram.java:32: not a statement (v.inStock()) ? out.print( "<td> yes </td>" ) : out.print( "<td> no </td>" );
posted 13 years ago
In the ?: ternary operator, the first operand must be a boolean expression, which you clearly have. The second and third operands must be expressions. You do not have expressions, you have statements. It should work this way: