ng.nalize() Method - Tutorialspoint
Maybe your like
Description
The Java Object finalize() method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.
Declaration
Following is the declaration for java.lang.Object.finalize() method
protected void finalize()Parameters
NA
Return Value
This method does not return a value.
Exception
Throwable − the Exception raised by this method
Example
The following example shows the usage of java.lang.Object.finalize() method. In this program, we've created a class ObjectDemo by extending GregorianCalendar class. In main method, finalize is called and object is made available for garbage collection.
package com.tutorialspoint; import java.util.GregorianCalendar; public class ObjectDemo extends GregorianCalendar { public static void main(String[] args) { try { // create a new ObjectDemo object ObjectDemo cal = new ObjectDemo(); // print current time System.out.println("" + cal.getTime()); // finalize cal System.out.println("Finalizing..."); cal.finalize(); System.out.println("Finalized."); } catch (Throwable ex) { ex.printStackTrace(); } } }Output
Let us compile and run the above program, this will produce the following result −
Sat Sep 22 00:27:21 EEST 2012 Finalizing... Finalized. java_lang_object.htm Print Page Previous Next AdvertisementsTag » What Is Finalize In Java
-
Finalize() Method In Java And How To Override It? - GeeksforGeeks
-
Java Object Finalize() Method With Examples - Javatpoint
-
Finalize() Method In Java - Scaler Topics
-
A Guide To The Finalize Method In Java - Baeldung
-
Java Finalize 함수 - 기술 블로그
-
How To Handle Java Finalization's Memory-Retention Issues - Oracle
-
Finalize In Java | Complete Guide To How Finalize() Method Work In ...
-
When Is The Finalize() Method Called In Java? - Stack Overflow
-
Finalize Method In Java - Gate Vidyalay
-
Finalize - The Java Interview Handbook: 300+ Interview Questions
-
Time To Say Goodbye To The Finalize Method In Java - Medium
-
Finalize Method In Java And Best Practices - JavaGoal
-
[PDF] Java Finalize Method, Orthogonal Persistence And Transactions
-
Finalize() Method In Java With Examples - CodeSpeedy