I get a compilation error while trying to compile, \"not a statement\", and the code is:
(checkDatabaseExist())?connectToDB() : buildDB();
when
As stated in JLS - Section 15.25 - Conditional Operator: -
It is a compile-time error for either the second or the third operand expression to be an invocation of a void method.
So, you must use an if-else
construct to invoke your methods on different condition.
if (checkDatabaseExist()) {
connectToDB();
} else {
buildDB();
}