Amigos Amigos - 1 year ago 95
Java Question

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
ternary statement can be used without
Assuming i have the following code, i wish to close the
if it is not null

(I am using Java programming language.)

PreparedStatement pstmt;


(pstmt!=null) ? pstmt.close : <do nothing>;

Answer Source

no you cannot do that. just do this:

if(bool1 && bool2) voidFunc1();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download