| ||Exception Handling - slide 27 : 30|
Comparison with exception handling in Java
The catch or specify principle: A method either catches and handles an exception, or
it specifies that it may throw the exception
- In Java
- the signatures of methods are extended with a throws clause
- tells that the method may throw a given exceptions
- a branch of the exception hierarchy - the so-called RuntimeExceptions -
is exempted from the catch or specify principle
- In C#
- all exceptions correspond to Java RuntimeExceptions
A Java program - does not compile.
A Java program - main handles Problem.
A Java program - main specifies Problem.