Java – if statement1 min read

Among the decision making statements, if- statement is the most simple one.
It checks if the condition is true or not, and if it is true then it executes the block of code inside if otherwise, it will not. The block that is executed is placed within the curly braces({}).

Syntax of if statement in Java:

Example of if statement in Java:


if…else statement in Java.
nested if statement in Java.
if-else-if ladder in Java.
switch statement in Java.