answersLogoWhite

0

The idea of the finalizer method was to do clean up stuff, like releasing IO resource to a database

or a file, as this method is called just before the garbage collector removes the object from memory.

The problem is that you cannot influence when or IF the garbage collector will clean up your object,

so you have no guarantee that the finalize method is ever called.

There are even more issues with the finalizer method, the shorty story is to just avoid it

and use a "try finally" block instead - closing the resources in the finally block will guarantee that

the resources will be released.

If you want to know more, I have a free video both about the finalizer method as well as exception handling on my blog (just Google for "Marcus Biel Clean Code Course")

User Avatar

Wiki User

9y ago

What else can I help you with?

Continue Learning about Engineering

When do you override the finalize method?

when there is cleanup activity needed before an object is destroyed


What indicates that a work breakdown structure has been finalized?

A work breakdown structure (WBS) is considered finalized when all project deliverables and tasks have been clearly defined and organized into a hierarchical structure, with no further changes anticipated. Stakeholder approval and consensus on the WBS are also crucial indicators of its finalization, ensuring that all parties agree on the scope and details. Additionally, a finalized WBS typically includes assigned responsibilities, estimated resources, and timelines, making it ready for execution and project planning.


What is the difference between garbage collector and finalization?

When all references to an object is Java are gone, the garbage collector will come along and free up the memory used by that object.Every Java object has a method named finalize, which is called by the garbage collector when the memory for that object is being deallocated. "Finalization" is just a name given to the act of calling the finalize method during garbage collection.


What does the finalize method do in java?

The "finalize" method is called when an object is removed from memory. If you need to do any cleanup (closing streams/files, displaying output, etc.) you can put it in an overridden finalize method.


Why java does not support destructor?

AMIT KUMAR3th Nov , 2014Java does not support destructors, since java supports the concept of garbage collection,hence the garbage collector is used to automatically free the space which has occupied by the program while running.Garbage collector calls the finalize() method which is defined in the object class. finalize() method is called once for each object.

Related Questions

What did the gadsden purchase finalize?

finalized the southern boundary of the continental United States


How long does it take to finalize a divorce in Arkansas after the final court date?

It's finalized the day you go for your final court hearing.


What is finalized DVD?

A burned DVD will not work in most DVD players until it's finalized. You can still view the DVD in a computer's DVD burner. When creating movies, home videos, and slide shows, you will want to finalize the DVD in order to play it on any DVD player. Finalizing a DVD means you won't be able to change or add anything else to the disk. All DVD creation programs allow you to finalize DVDs with the click of a button.


What words start with the word final?

Final Exam, Final answer, Final jeopardy, Final Score, Final Words, Final chapter, Final Draft , Finally,Finale, Finalize, Finalized, Finals


What is the verb of final?

Finalize


Name somthing that starts with the word final?

Lots of options: Finalising Finalities Finalizers Finalizing Finalised Finalises Finalisms Finalists Finalized Finalizer Finalizes Finalise Finalism Finalist Finality Finalize Finales Finalis Finally Finale Finals


A sentence for the word finalize?

I had to check my work and finalize my answers.


How do you spell finalise?

"Finalize" is spelled with a "z" in American English and with an "s" in British English: "finalize" and "finalise," respectively.


What were the circumstances surrounding the writing of the star Spangeled Banner?

Francis Scott Key went to the British fleet located in Chesapeake Bay to finalize the release of Dr. William Beanes. Mr. Key was detained on the ship after the release was finalized due to the shelling of Fort McHenry.


Can you stop the divorce after it has been finalized?

No. That's why it's called 'finalized'.


What is the Verb form of final?

Finalize


What is the past participle of finalize?

Finalised.