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<
a ? b : c
if<
You cannot use ternary without else, but to do a "if-without-else" in one line, you can use Java 8 Optional class.
Optional
PreparedStatement pstmt; //.... Optional.ofNullable(pstmt).ifPresent(pstmt::close); // <- but IOException will still happen here. Handle it.