HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 65 Class Finalizers

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * Important Information in IMAGE

Any class can have an optional finalizer that will perform any necessary clean-up needed when garbage collector (which is automatic in Java) tries to delete object and free-up resources it uses
An example is given for an object that uses an I/O stream and needs to close it on termination
protected void finalize() {
  • try {
    • file.close();
  • } catch (Exception e) { /* Catches ANY exception */
  • }
}
Earlier one might have set this up with syntax such as that on next foil



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Feb 18 1997