How To Learn Exception Handling in Java?

Page 1

Do you know about Exception Handling in Java?

ď ľ

ď ľ

An exception is a problem that occurs during the performance of a system. When an Exception happens the regular flow of the system is disturbed and the program/Application ends unusually, which is not suggested, therefore these exclusions are to be handled.


Java - Exceptions


Exception Handling in Java An exception can take place for many different reasons, below given are some circumstances where exception happens. 

A customer has given incorrect information.

A file that needs to be opened out cannot be found.

A system connection has been missing at the center of emails or the JVM has run out of storage.


Exception Hierarchy 

All exception is subtypes of the java.lang.Exception class. The exception category is a subclass of the Throwable class. Other than the exception class there is another subclass known as Error which comes from the Throwable class. Errors are irregular circumstances which occur in case of serious problems, these are not managed by the java applications. Errors are produced to indicate mistakes produced by the runtime atmosphere. Example : JVM is out of Memory. Normally applications cannot restore from mistakes. The Exception class has two main subclasses: IOException


Exception Hierarchy


Exception Methods  

 

 

Public String get Message() Returns a detailed concept about the exception that has happened. This concept is initialized in the Throwable construtor Public Throwable getclause() Clause is returned of the exception as showed by a Throwable item. public void printStackTrace() Prints a outcome of toString() along with the collection track to System.err, the big mistake outcome flow.


Exception Methods  

 

 

Public String get Message() Returns a detailed concept about the exception that has happened. This concept is initialized in the Throwable construtor Public Throwable getclause() Clause is returned of the exception as showed by a Throwable item. public void printStackTrace() Prints a outcome of toString() along with the collection track to System.err, the big mistake outcome flow.


Exception Methods


ď ľ ď ľ

public String toString() Returns the class name concatenated with an outcome of getMessage()

public StackTraceElement [] getStackTrace() Returns an range containing each factor on the collection track. The factor at catalog 0 symbolizes the top of the decision collection, and the last look at the range symbolizes the method at the bottom of the decision collection. public Throwable fillInStackTrace() Fills the collection track of this Throwable item with the current collection track, adding to any previous information in the collection track. You can go through the java tutorial to know more about Java programming.


Thankyou


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.