explain which statement is more efficient and why reason (if or switch)
Answers
Answered by
5
Answer:
A switch statement is usually more efficient than a set of nested ifs. ... The compiler can do this because it knows that the case constants are all the same type and simply must be compared for equality with the switch expression, while in case of if expressions, the compiler has no such knowledge
Explanation:
please mark me as brainlist
Answered by
2
Explanation:
A switch statement is usually more efficient than a set of nested ifs. ... Check the Testing Expression: An if-then-else statement can test expressions based on ranges of values or conditions, whereas a switch statement tests expressions based only on a single integer, enumerated value, or String object
Similar questions