# An exception is an abnormal condition that arises in a code sequence at run time.
Java exception handling is managed via five keywords : -
Try, Catch, Throw, Throws and Finally
Try : -
Program statements that you want to monitor for exceptions are contained within a try block.
Catch : -
Catched an exception.
Throw : -
To manually throw an exception use the keyword throw.
Throws : -
Any exception that is thrown out of a method must be specified as such by a throws clause.
Finally : -
Any code that absolutely must be executed after a try block completes is put in a finally block.
# Once an exception is thrown program control transfers out of the try block into the catch block.
java.lang.Arithmetic Exception: divide by zero
at exc2.main(exc2.java.18)
Java exception handling is managed via five keywords : -
Try, Catch, Throw, Throws and Finally
Try : -
Program statements that you want to monitor for exceptions are contained within a try block.
Catch : -
Catched an exception.
Throw : -
To manually throw an exception use the keyword throw.
Throws : -
Any exception that is thrown out of a method must be specified as such by a throws clause.
Finally : -
Any code that absolutely must be executed after a try block completes is put in a finally block.
# Once an exception is thrown program control transfers out of the try block into the catch block.
java.lang.Arithmetic Exception: divide by zero
at exc2.main(exc2.java.18)
No comments:
Post a Comment