mercredi 27 avril 2016

Why is the switch statement to be avoided in Java?

One of my teachers said that we should avoid using the switch statement. Why? what's bad about it?

I find it to be useful if you have an if statement with 4 or 5 else if. With the switch once it hits what it's looking for, it leaves the switch block. While with an if, else if statement, it will verify every else if even if it "entered" one already.

Aucun commentaire:

Enregistrer un commentaire