Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Which is more efficient, a switch statement or an if else chain?
Which is more efficient, a switch statement or an if else chain?
✍: Guest
The differences, if any, are likely to be slight. The switch statement was designed to be efficiently implementable, though the compiler may choose to use the equivalent of an if/else chain (as opposed to a compact jump table) if the case labels are sparsely distributed.
Do use switch when you can: it's certainly cleaner, and perhaps more efficient (and certainly should never be any less efficient).
2015-02-04, 1291👍, 0💬
Popular Posts:
.NET INTERVIEW QUESTIONS - What is the difference between thread and process? A thread is a path of ...
How do you estimate maintenance project and change requests?
How To Specify Two Background Images on a Page? - CSS Tutorials - Page Layout and Background Image D...
How can I enable session tracking for JSP pages if the browser has disabled cookies? We know that se...
What is Shell scripting A shell script is a script written for the shell, or command line interprete...