Java try catch not handling IndexOutOfBoundsException
<p>I was having some problem when try to try catch the IndexOutOfBoundsException for a List in Java. So I declared my list with 2 elements as:</p>

<pre><code>List&lt;String&gt; list = new ArrayList&lt;&gt;(Arrays.asList("item1", "item2"));
</code></pre>

<p>Then I tried to do a try catch:</p>

<pre><code>do {
    for (int i = 0; i &lt; list.size(); i++) {
        System.out.print("(" + (i + 1) + ")" + list.get(i));
    }
    System.out.println(" ");

    try{
        option = sc.nextInt();
    } catch (IndexOutOfBoundsException e){
        System.out.println("Invalid option");
        sc.next();
        continue;
    } catch (InputMismatchException e) {
        System.out.println("Option input mismatch.");
        sc.next();
        continue;
    } 
    sc.nextLine();
    if (option == 1) {
        System.out.print("Enter name: ");
        // scanner takes in input
    } else if (option == 2) {
        System.out.print("Enter desc: ");
        // scanner takes in input
    }
type = list.get((option - 1));
} while (option &lt;= 0 || option &gt;= 3);
</code></pre>

<p>However, when I entered anything larger than 2 for option, it threw me IndexOutOfBounds exception but I thought I did a try catch for it already?</p>

<p>Thanks in advance.</p>