title: if else vs switch performance in java
body: <p>I'd like to know if there is any efficiency difference between using if statement or switch. For example:</p>
  
  <pre><code>if(){
  //code
  }
  else if(){
  //code
  }
  else{
  //code
  }
  </code></pre>
  
  <p>I believe that program needs to go and check all of the if statement even if the first if statement was true.</p>
  
  <pre><code>switch(i){
  
  case 1:
  //code
  break;
  case 2:
  //code
  break;
  </code></pre>
  
  <p>But in the switch, there is a break command. Is my approaching right? If not, could you explain the efficiency difference between them?</p>