Professional Documents
Culture Documents
Chakradhar: Presentation by
Chakradhar: Presentation by
Chakradhar
Exception Handling
PROGRAMMING
ERRORS
try{…….}
try{……}
catch(Exception e){…..}
finally{…..} finally{…..}
throw
• It is used to throw an Object of Exception
type or any User Defined Exceptions.
Examples: Examples:
IOException ArithmeticException
RemoteException FileNotFoundException
SocketException NumberFormatException
AllUserDefined ArrayIndexOutOfBounds
Exceptions Exception
throws
• ‘throws’ is used to specify Exception
in method declaration from where the
checked exceptions are thrown.
syntax:
returntype method(Args) throws CheckedException
{
statements;
}
User Defined Exceptions
• A class extended from Exception by
overriding the toString() method.
if(value<=0)
{
MyException me=new MyException();
throw me;
}