Why should I used try catch (in spite of not commiting error)

Posted on 2009-02-13
Last Modified: 2012-08-14
I have been using try-catch since the day I learned Java. Now my doubt is why is it I am forced to use a try catch in case I am not commiting an error to be caught. The cause of this doubt was when I was writing a code to parse an xml,
<documentbuilder object>= <documentbuilderfactory object>.somemethod().
This line above if not place in a try catch it gives an error.

Can anyone explain it. Thanks.
Question by:rmvprasad
    LVL 86

    Accepted Solution

    Some exceptions have to be caught - you're forced to catch them. Runtime ones, you're not forced to
    LVL 86

    Expert Comment

    LVL 86

    Expert Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    If you have upgraded to Java2 update 10 on a Microsoft Windows client, you may have discovered that your Java application does not work as it did before.  For example, the colors of your Java2D graphic may be all wrong for no apparent reason. Aft…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now