Lesson 7 of 34
else if: Many Choices
8 min 25 XP
Use else if when there are more than two choices. Java checks from top to bottom and runs only the first block whose condition is true.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Order matters! Check the biggest range first. If temp >= 15 came first, even 40 would print "Pleasant".