Skip to content
Advertisement

Tag: ternary-operator

Ternary Operators Java

Is there a way to implement this in a ternary operation. I’m very new to that ternary stuff, maybe you could guide me. This one doesn’t seem to work. Answer In this case, you don’t even need a ternary operator: Or, cleaner: Your version: is semantically incorrect: ternary operator should represent alternative assignments, it’s not a full replacement for if

If without else ternary operator

So far from I have been searching through the net, the statement always have if and else condition such as a ? b : c. I would like to know whether the if ternary statement can be used without else. Assuming i have the following code, i wish to close the PreparedStatement if it is not null (I am using

Advertisement