finalize() is a method called by the garbage collector. It ensures that there are no more references left. Basically, it is called to perform the clean-up function which can be like shutting down the database connection, network connection or closing any other resource connections. Once the finalize() is completes its execution, the Garbage Collector immediately destroys that object.
Syntax of finalize() in the Object class is:
protected void finalize throws Throwable{}
Later, you need to override this method to customize it, according to your needs.
Also, this method is generally called when an object is left unattended for a long period of time so chances are there that it might be never called in a lifetime of a program.