Catch keyword In Java

Compiled By Unknown - No Comments
The catch keyword is used to define exception handling blocks in try−catch or try−catch−finally statements.
Remarks Catch keyword In Java
  • The opening and closing curly braces { and } are part of the syntax of the catch clause and may not be omitted even if the clause contains a single statement.
  • Every try block must have at least one catch or finally clause.
  • If a particular exception class is not handled by any catch clause, the exception propagates up the call stack to the next enclosing try block, recursively. If an exception is not caught by any enclosing try block, the Java interpretor will exit with an error message and stack trace.

  • Example
    
    try
    {
    
    }
    catch ( e)
    {
    
    }
    try
    {
    
    }
    catch (FooException e)
    {
    
    }
    catch (BarException e)
    {
    
    }
    try
    {
    
    }
    catch ( e)
    {
    
    }
    finally
    {
    
    }
    


    Tags:

    No Comment to " Catch keyword In Java "