java finalized method

Java Object class has a method called finalize which is provide for garbage collector. Actually garbage collector (GC) cleans up objects from heap after certian time. We have a seperate article for how garbage collector works. You can read it latest. As a develop you might need to do some works at the time your class Object get deleted by GC. So you can override finalized method which is provided by Java Object class and if you did not override it will call Object class method.

Note : All this is up to Java 8 and from Java 9 onwards it is deprecated.

https://docs.oracle.com/javase/9/docs/api/java/lang/Object.html#finalize–

Java Object class documentation :-

https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html

Leave a Reply