functional if else java code example
Example 1: how to make if else statments in java
if (condition) {
// code block
} else {
// code block
}
Example 2: else if java
else if statement is used to specify new condition if first condition is false.
Syntax:
if(condition1)
{
// execute if condition1 is true
}
else if (condition2)
{
// execute if condition2 is true
}
else if (condition3)
{
// execute if condition3 is true
}
else
{
// execute if conditions 1, 2 and 3 becomes false
}