How to implement try-catch in java - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How to implement try-catch in java

ginualexginualex kottayamPosts: 109Member
                                  The YouTube video tutorial ,  will show you how to implement try catch in java.

                                     YouTube link address :::::::::::


  • manishamanisha Posts: 32Member
    edited June 29

    Try-Catch is used to handle the exceptions in java.

    Exception is a run-time error in java which occurs due to logical errors in program. Exception is a class in java.

    There are two ways of handling the Exception:

    1) Throws Keyword
    2) Throw Keyword

    1) Throws Keyword: It is used to handle exception like DivideByZero, ArrayIndexOutOfBoundsException i.e. exceptions which are system defined.

    Example: If you are using BufferedReader in java, IOException is thrown.

    2) Throw Keyword:
    Throw keyword is sued to handle user defined exceptions Like the age of person should be greater than zero. To achieve this, one must define class extending the Exception keyword.

    For more Details Refer following link:

Sign In or Register to comment.