+ 1
Can someone explain the order of if-else and nested-if in easier way? I have read and practiced but still mixed up :) #java
i started to confuse when I saw the 'else if' after 'else' statement. Sorry for the grammar :)
5 ответов
+ 1
you use 'else if' if there are more than one conditions to be met:
if its raining
take unbrella
else if sun is shining
take sunglasses
else if its windy
take a jacket
else
youre good to go
+ 1
nested ifs work like this:
if you see a person
if its a friend
say "oh hi mark"
if its a stranger
say "hello stranger"
else
say nothing
0
about your second answer Kevin Dietrichstein, the 'else statement' is connected to the first if or the last one? thx for explain it by the way ^^
0
to the very first, you have to look at the indent of the statements and you know what is connected
0
so, can u give another example of if-else and nested if? more complicated than this. I understand the examples but I totally get lost when it comes to start :( Kevin Dietrichstein