Exception Handling


Exception handling allows you to respond to exceptions that might occur while your program is running. The Fortran language has no built-in exception handling. You can create your own exception handling in a Fortran program if you like. Normally this involves testing for exceptions using a series of IF-ELSE IF statements. The problem with this approach is you have to do all the work yourself. Unforeseen errors might slip through your exception handling code, and the exception handling must take place where the exception will occur. You can't pass the exception handling off to another part of the code.

Exception handling is an integral part of the Java language. Built-in classes and programming constructs make it easy to build exception handling into your programs. Exception handling is performed by defining specialized blocks of code. One type of block throws an exception to another type of block that catches and processes the exception. A third type of code block can be called after all the exception handling takes place. What's more, the exception handling can be passed on to another part of the program. The exception handling does not have to be performed where the exception occurs.

The Java compiler will check that you are handling certain types of exceptions. If the appropriate safeguards aren't built in to your program, the code won't compile. This sounds a bit annoying but is actually a nice feature. Sometimes errors occur but the program keeps running, generating garbage data. The Java compiler will alert you to potential exceptions, allowing you to make arrangements in your code to handle them.



Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net