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

  • Home
  • SEARCH
  • 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 538169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:00:12+00:00 2026-05-13T10:00:12+00:00

http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization Is this design pattern possible in Java? If so, how? If not, why

  • 0

http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization

Is this design pattern possible in Java? If so, how? If not, why not?

Thanks!

  • 1 1 Answer
  • 3 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-13T10:00:12+00:00Added an answer on May 13, 2026 at 10:00 am

    The same Wikipedia page that you linked to has a section on Java, quote:

    Hence the “finalize” method of an unreferenced object might be never called or called only long after the object became unreferenced. Resources must thus be closed manually by the programmer, using something like the dispose pattern.

    void java_example() {
      // open file (acquire resource)
      final LogFile logfile = new LogFile("logfile.txt");
    
      try {
          logfile.write("hello logfile!");
    
          // continue using logfile ...
          // throw exceptions or return without worrying about closing the log;
          // it is closed automatically when exiting this block
       } finally {
          // explicitly release the resource
          logfile.close();
       }
    }
    

    The burden of releasing resources falls on the programmer each time a resource is used.

    I think there is a proposal for Java 7, which would create Closeable classes, and some syntactic sugar for the try blocks to make this more concise (but you still have to write that try block).

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

Sidebar

Ask A Question

Stats

  • Questions 489k
  • Answers 489k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For me the (first) linked article has a fundamental problem:… May 16, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer $1 was empty, so the match did not succeed. I'll… May 16, 2026 at 9:00 am
  • Editorial Team
    Editorial Team added an answer This can be automatically done using Eclipse Helios. In your… May 16, 2026 at 8:59 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

From http://en.wikipedia.org/wiki/AJAX , I get a fairly good grasp of what AJAX is. However,
http://en.wikipedia.org/wiki/ICalendar I'm working to implement an export feature for events. The link above lists
I've seen this advice... ideally the web should follow the REST principle and be
I'm trying to improve my current algorithm for the 8 Queens problem, and this
Java has some very good open source static analysis tools such as FindBugs ,
How can I make xargs execute the command exactly once for each line of
I hear people talking about dependency injection and the benefit of it all the
I have been working on an iPhone App for a couple of weeks now
Lastly I've been feeling like jQuery is slowly becoming the defacto standard in JS

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.