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 8753501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:26:15+00:00 2026-06-13T13:26:15+00:00

Possible Duplicate: Why use Finally in Try … Catch Why should we not use

  • 0

Possible Duplicate:
Why use Finally in Try … Catch

Why should we not use the catch block to clean up code?

I have not used the error-handling techniques as much, but am starting to use them for just about every program now. about time

So, while going through articles/documentations, i came across the finally block.

And as it suggests, the finally block runs irrespective of whether there is an exception or not(Of course it wont run, if there is a forced shutdown of the JVM or the PC). Also finally block is usually used for cleaning up code(resources).

So basically, if my code does not have an exception coming up, then why should i clean up the code. Shouldn’t i put the cleanup code in the catch block rather than the finally block.

I tried looking for questions similar, but none asked this question it seems. So i went ahead and created a question 😀

  • 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-06-13T13:26:16+00:00Added an answer on June 13, 2026 at 1:26 pm

    Because the catch block is not guaranteed to execute. The finally block does have such a guarantee, unless you kick the power cord out of the wall.

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

Sidebar

Related Questions

Possible Duplicate: Should I use != or <> for not equal in TSQL? Behavior
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: Should I use Elements or Attributes in XML? I have never been
Possible Duplicate: How to use include within a function? i have two file inc.php
Possible Duplicate: Use of class definitions inside a method in Java Can we have
Possible Duplicate: Weird use of void I was reading C code and came across
Possible Duplicate: Use Linq to Xml with Xml namespaces I have an xml: <?xml
Possible Duplicate: Use Visual Studio web.config transform for debugging I have an asp.net application
Possible Duplicate: Why use getters and setters? I have read books on Java, saying
Possible Duplicate: Testing use of NSURLConnection with HTTP response error statuses This is bizarre;

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.