title: Exception handling in a switch
body: <p>The following code is in a while loop which then houses a switch as such:</p>
  
  <pre><code>  System.out.println("Enter in a selection.");
    System.out.println("Enter \"1\" for a default selection of die");
    System.out.println("Enter \"2\" for a custom number of sides.");
    //try the input to see if its an integer
    try {
    selection = sc.nextInt();
    } catch (NumberFormatException e){
        System.out.print("Your selection can only be an integer!");
     } 
   switch (selection){
     case1:
     ...
     break;
  
     case2:
     ...
     break;
  
     default:
     ...
     //yell at them
     continue;
    }
  </code></pre>
  
  <p>I already have a default selection in the switch so that if a user enters in an invalid number like 4 (since there are only 2 cases) that it brings them back to the beginning of the loop. So, the issue is handling the exception. The exception does not get handled with the following above code and I don't know why. The try is housing the offending code. </p>
  
  <p>As always, please ask for clarification if needed. Thanks.</p>