Nesting try/catch Statements : Try Catch « JSP « Java






Nesting try/catch Statements

<HTML>
    <HEAD>
        <TITLE>Nesting try/catch Statements</TITLE>
    </HEAD>

    <BODY>
        <H1>Nesting try/catch Statements</H1>
        <%
        try {
            try {
                int c[] = {0, 1, 2, 3};
                c[4] = 4;
            } catch(ArrayIndexOutOfBoundsException e) {
                out.println("Array index out of bounds: " + e);
            }

        } catch(ArithmeticException e) {
            out.println("Divide by zero: " + e);
        }
        %>
    </BODY>
</HTML>

           
       








Related examples in the same category

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