The if ... else ... else ... if Statement

This statement tells the program to execute only if a given section of code evaluates to true.

Conditionally executes a group of statements, depending on the value of an expression. You can use either block form syntaxes:

if condition statements [else elsestatements]

              or

if condition 
    { statements }
[else if condition-n
    [    { elseifstatements    } ] ] ...
[else
    [    {  elsestatements   } ]  ]

You can use the single-line form (first syntax) for short, simple rules. However, the block form (second syntax) provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and test.

The else and else if clauses are both optional. You can have as many else if statements as you want below a block if, but none can appear after the else clause. Block if statements can be nested that is, contained within one another.