title: What is the runtime complexity of a switch statement?
body: <p>I'd like to know what the worst-case runtime complexity of a switch statement is, assuming you have <em>n</em> cases.</p>
  
  <p>I always assumed it was <em>O(n)</em>. I don't know if compilers do anything clever, though. If the answer is implementation-specific, I'd like to know for the following languages:</p>
  
  <ul>
  <li>Java</li>
  <li>C/C++</li>
  <li>C#</li>
  <li>PHP</li>
  <li>Javascript</li>
  </ul>