February 5, 2011

finalize method in Java

The finalize() method can be overridden in any Java class (from the Object class), and will be invoked and executed by the JVM just before the object is deleted by the Garbage collector.

public class Test {

   public void finalize() {
      System.out.println("In finalize method");

   public static void main(String[] args) {
      Test t = new Test();
      t = null;

No comments:

Post a Comment