Tutorial :What is the function declaration for the Java finalize method?



Question:

I've been searching code for the finalize for nearly 1 mon. Can u pls help me for the code. Thanks in advance.


Solution:1

finalize

protected void finalize() throws Throwable  {      try      {          //close unmanaged resources      } finally {          super.finalize();      }  }  

Note that outside of unmanaged resources, you shouldn't ever be doing this..


Solution:2

protected void finalize() throws Throwable {      try {          close();        // close open files      } finally {          super.finalize();      }  }  

You call super.finalize() in the finally block.

Source


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »