"Though you clean all non-java resources in finalize() method, it is a good practice to clean all non java resources in all the functions where ever you are using it." why?
Because there is no guarantee that JVM's GC will call finalize method before cleaning an object.
Because there is no guarantee that when GC will run, so we don't know when finalize will be called, so we can't hold important system resources for too much of time, as there are very limited system resources will be available for processes.
Though we know that when GC will clean the object, but still we can't guarantee whether GC will call finalize() method of that object before cleaning or after cleaning that object.
this statement is not true.
Back To Top