Exception Handling
Exception Handling
Handling
in Java
- S I VA J I L AV E T I
Introduction to Exception
Handling
1.What is an Exception ?
• Throws
•Used to indicate what exception type may be thrown by a
method
• throw
•Used to throw an exception for a method
Syntax:
void methodName() throws
ExceptionType {
// code
}
// Main method propagates the exception
} else {
System.out.println("Valid age.");