An else-if statement extends the basic if-else structure to handle multiple conditions in sequence. It allows you to check additional conditions if previous if or else-if conditions were false, providing more than two paths of execution.
int number = -5;
if (number > 0) {
System.out.println("Positive");
} else if (number < 0) {
System.out.println("Negative");
} else {
System.out.println("Zero");
}Output
Negative