2

Example:

if(Boolean){
    if(Boolean) something();
    else if(Boolean) something(); 
    else something();
           }

This is the same as

if(Boolean)
    if(Boolean) something();
    else if(Boolean) something(); 
    else something();

Is if, else if and else count as one statement?

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
Harout Tatarian
  • 431
  • 4
  • 14

1 Answers1

3

An if/else pair is one statement. If you have if/else if/else, that's actually two if statements, with the second one being in the first one's else clause.

if(Boolean)                                                 \
    something(); <- one statement                           |
else                                                        | one
{                                                           | if
    if(Boolean)                              \              | statement
        something(); <- one statement        | one if       |
    else                                     | statement    |
        something(); <- one statement        /              |
}                                                           /
user253751
  • 57,427
  • 7
  • 48
  • 90