您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)
Extend Index

Extend Page # 1

Destructor methods

Objects can be created and destroyed by programs. Part of a class definition can be a method, called a destructor, that is executed when the object is to be destroyed. In Java such a method must have the identifier finalise, and an example might be:

protected void finalise(  )

  {

  System.out.println("now destroying object");

  }

This particular destructor method is not very useful, however, it illustrates that it is possible to add a destructor method to classes, so that actions can be performed by an object being destroyed.

Back to top

 basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg