Java – In servlet destroy() is called first or finalize()

javaservlets

In a servlet, is destroy() called before or after finalize()?

Best Solution

destroy() is called first. destroy() will be called by the servlet-container at the time the servlet will be shut-down. finalize() is called by the JVM before the garbage-collector claims the objects (and isn't guaranteed to be called at all).