Nested If Else
means one variation of if-else
structure can contain any variation of if-else
structure.
For example, if
body can contain, another if
structure, or if-else
structure, or else-if
block etc. Similarly else
block can also contain any variation of if-else
structure.
This way you can have if-else
structure inside another if-else
structure. And inner if
block or else
block can also contain another if-else
block, and this way you can go deeper without any limitation. Though you can nest if else block as deep as you can, but in real life situation we rarely encounter where we need to nest the structure more then two level.
Here is an example -
if(condition1){ // statement 1 if(condition2){ // statement 2 }else{ // statement 3 } }else{ if(condition3){ if(condition3){ // statement } // statement } if(condition4){ }else if(condition5){ }else if(condition6){ }else{ } }