Syntax of if-else Statement
if (condition) { // Executes this block if // condition is true } else { // Executes this block if // condition is false }
Java if-else
Decision-making in Java helps to write decision-driven statements and execute a particular set of code based on certain conditions. The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. In this article, we will learn about Java if-else.