Question:

Can anyone explain what try catch and throw are to be written in a java program?

by  |  earlier

0 LIKES UnLike

with an example

 Tags:

   Report

1 ANSWERS


  1. In try block you write code which you assume can give error/exception at run time for eg : creating database connection, access a file ...

    In catch block you handle the error / exception , best practice is to Log it into database or a flat file.

    You throw an exception so that it is handled by appropriate routine

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.