Multiple Catch : Try Catch « JSP « Java






Multiple Catch

<HTML>
    <HEAD>
        <TITLE>Catching an ArrayIndexOutOfBoundsException Exception</TITLE>
    </HEAD>
    <BODY>
        <H1>Catching an ArrayIndexOutOfBoundsException Exception</H1>
    <%
    try {
        int array[] = new int[100];
        array[100] = 100;
    } catch (ArrayIndexOutOfBoundsException e) {
        out.println("Array index out of bounds.");
    } catch(ArithmeticException e) {
        out.println("Arithmetic exception: " + e);
    } catch(Exception e) {
        out.println("An error occurred: " + e);
    }


    %>
    </BODY>
</HTML>

           
       








Related examples in the same category

1.Using a try/catch Block
2.Nesting try/catch Statements
3.Printing a Stack Trace to the Server Console