
Throw, Throws and Finally Keywords 7.9
7.7 Throw, Throws and Finally Keywords
7.7.1 Using Finally Block
Usually when an exception occurs, the exception handling code may initiate a re-run to the
system or the calling program. At that instant of time, there are several actions to be performed
like closing of all open files and restoring the state to a state prior to occurring of the exception.
This is accomplished by using the finally() as shown in Example 7.5. It is included after
the last catch block.
Example 7.5: Using of Finally Block
try
{ // aloocation code here
public void DisplayNumbers() throws NumberFormatException{
//display code ...