+ 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 :)

29th Sep 2018, 4:12 PM
Audrey Ardelia
Audrey Ardelia - avatar
5 odpowiedzi
+ 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
29th Sep 2018, 4:22 PM
Kevin Dietrichstein
Kevin Dietrichstein - avatar
+ 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
29th Sep 2018, 4:24 PM
Kevin Dietrichstein
Kevin Dietrichstein - avatar
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 ^^
29th Sep 2018, 4:28 PM
Audrey Ardelia
Audrey Ardelia - avatar
0
to the very first, you have to look at the indent of the statements and you know what is connected
29th Sep 2018, 4:45 PM
Kevin Dietrichstein
Kevin Dietrichstein - avatar
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
30th Sep 2018, 12:28 AM
Audrey Ardelia
Audrey Ardelia - avatar