title: nextLine().charAt(0) inside a switch statement
body: <p>I'm making a very basic calculator program and ran into a problem that's baffled my mind the entire time.</p>
  
  <p>Code:</p>
  
  <pre><code>switch(operation){
        case 'a':
        case 'A':
            addition(n);
            operation = n.nextLine().charAt(0);
            break;
  </code></pre>
  
  <p>When I run the program and enter either characters (proceeding code uses Scanner object n to determine which char I type in), the method addition(n) works as intended. Basically the switch statement is inside a while loop so that it executes until I enter 'E', and the 5th line in the code I have above will change the char operation so that it does not execute the addition switch block over and over. The 5th line <code>operation = n.nextLine().charAt(0);</code> will give me an error:</p>
  
  <pre><code>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
  </code></pre>
  
  <p>Why is it giving me this error? What troubles my mind more is my default inside the switch is structured similarily yet the exact same code will work for it.</p>
  
  <pre><code>  default:
        System.out.println("Invalid entry. Refer to above menu and input"
                + " your choice of operation.");
        operation = n.nextLine().charAt(0);
        break;
  </code></pre>
  
  <p>Many thanks for your time.</p>
  
  <p>EDIT: If I comment out the method <code>addition(n)</code>, the 5th line will work as fine, allowing me to change my char operation. Why is the 4th line responsible for this?</p>