Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:29:27+00:00 2026-05-27T20:29:27+00:00

When should we really use finalize() method in java? If we want to close

  • 0

When should we really use finalize() method in java?

If we want to close connection in finalize() method then it’s better to use the code below as waiting for GC to call finalize() method and then release the connection does not make sense

try{
// Connection creation
}finally{
//close connection
}

So the question is does finalize() method has any relevance today?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:29:28+00:00Added an answer on May 27, 2026 at 8:29 pm

    It is indeed preferable to release resources by calling a method explicitly. Finalizers are not necessarily called promptly or even at all. And they add a performance penalty.

    However, finalizers may still be used as a safety net to release resources, in case the client has forgotten to dispose explicitly.

    From the topic “Avoid finalizers” in Joshua Bloch’s “Effective Java,” 2nd ed.:

    [D]on’t use finalizers except as a safety net or to terminate noncritical
    native resources. In those rare instances where you do use a finalizer,
    remember to invoke super.finalize. If you use a finalizer as a safety net,
    remember to log the invalid usage from the finalizer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What should i use to code Classic ASP under Linux. I have really tried
I'm not really asking whether I should use either a RDBMS or config files
OK, this should really be asked to someone from Google, but I just want
This should really be allowed - I do not understand why it is not.
I really should upgrade to Firefox 3, but I'm very dependent on Firebug working
This should be really simple, but I have tried many solutions posted on the
I have an application which really should be installed, but does work fine when
This seems like it should be really simple, but I'm unable to figure this
I'm dealing with an annoying database where one field contains what really should be
Overview I am using CompositeWPF to create an app using C#. This really should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.