note 45434 deleted from language.oop5.decon by nlopess
| From: | nlopess@php.net | Date: | Tue, 07 Sep 2004 09:19:08 +0000 |
| Subject: | note 45434 deleted from language.oop5.decon by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76140@lists.php.net to get a copy of this message | ||
Note Submitter: taeber at rapczak dot com
----
<?php
// Quote from Documentation
"PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such
as Java. The destructor method will be called as soon as all references to a particular object are
removed or when the object is explicitly destroyed."
?>
I think this statement is a bit misleading. Java does NOT implement the destructor concept. The
closest equivalent that comes to mind is the "finalize()" method which is called when an
object is collected by the JVM garbage collector. There is not guarentee, however, that this method
will be called until the program has ended.
The only way to implement this concept in Java is to create a destructor method and call it
implicity from the client code. Again, there is no guarentee that the programmer writting the code
will use this method. Even then, the destructor is not the same as say C++'s destructors which
are functions that are automagically called whenever an object is destroyed.