If else if and switch
When will go for if else if and switch?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Midhun TpRank #388 · 6.5K reputationPosted Aug 18, 2016, 6:57 AM EDT
If you have a series of statements to check and only one among them will be true, then you can go with else if statement.
Tapan PatelRank #614 · 3.9K reputationPosted Aug 18, 2016, 7:11 AM EDT
Here is what you can do.
Actually you can use alternatively but going with if else requires compiler to do some extra work in case you have complex logic in conditions. Alternatively because, you can do something as
Nitin SontakkeRank #264 · 9.6K reputationPosted Aug 18, 2016, 7:58 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 18, 2016, 9:02 PM EDT