The else if Statement

Learn how an else-if structure works in Java.

What is an else if statement?

Java offers a multi-way selection process in the form of else if statement. There are a series of conditions with different code statements to be executed for each condition.

A multi-way selection is performed using if-else-if statements such that exactly one section of code is executed associated with the first condition that evaluates to true.


In this case, the body of the if statement is executed when the boolean condition is true. If not, then the next condition will be tested. The process will continue until the subsequent conditions evaluate to false. If none of the conditions is met, then eventually, the else block will execute.

Get hands-on with 1200+ tech skills courses.