Java Reference
In-Depth Information
associated with
if(i == 10)
. The inner
else
refers to
if(k > 100)
, because it is the closest
if
within the same block.
You can use a nested
if
to add a further improvement to the guessing game. This addition
provides the player with feedback about a wrong guess.
A sample run is shown here:
The if-else-if Ladder
A common programming construct that is based upon the nested
if
is the
if-else-if
ladder
.
It looks like this: