Matt Gerrans
Posts: 1153
Nickname: matt
Registered: Feb, 2002
|
|
Re: Destructor
|
Posted: Jun 22, 2002 11:38 PM
|
|
Welcome to Java. There are no destructors! There are finalizers, but you shouldn't think of them as destructors, since they are not guaranteed to ever be called (even is you do a System.gc()). If your class must free up some resource, then it should have a close() method that does this. You can use the finalizer to check that close() was called and display an error if the object was not properly closed before being collected, but this just is a form of spot-checking. Also, you would probably not want this in your released code, or you'd want it to be doing the check only when a debugging flag was set.
|
|