
if else statement Java
if then else statement in java
Syntax:
if (expression 1) { ……; } else { …..; } |
Description :
If the expression evaluates to true, the block of statements will be executed, if not else block of statements will be executed.
Example:
if (5<3) { System.out.println(“Will not be printed”); } else { System.out.println(“Will be printed”); } |
Output:
Will be printed |