If you have multiple clauses to test, it makes sense to add a switch statement instead of many if statements. Internally the compiler treats switch statements as if they were multiple if statements. Code-wise, however, switch statements are normally easier to follow and to maintain than several if statements all in a row. To write a switch statement:
Tips
|