Language syntax
Java else if chain
Test conditions in order; a later test is reached only if preceding ones are false.
Formal Syntax & Structure
java syntaxjava
if (a) { first } else if (b) { second } else { fallback }Working Example
Example Snippetjava
public class Main { public static void main(String[] args) { int n = 6; if (n < 3) { System.out.println("Low"); } else if (n < 8) { System.out.println("Mid"); } else { System.out.println("High"); } }}