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

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