Sunday, March 1, 2009

source code finalize method



package funds;

public class FinalizeDemo {
public static void main(String arg[])
{
String s=new String("java");
s=null;
System.gc(); //here string class finalize called
FinalizeDemo fd=new FinalizeDemo();
fd=null;
System.gc(); // this class finalize called
}
public void finalize()
{
System.out.println("finalize called");
}
}

output:
finalize called


1 comments:

Shailesh S.S. said...

Is finalize() method executed automatically like garbage collector?

Post a Comment