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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:53:05+00:00 2026-05-28T15:53:05+00:00

In this code: Properties prop = new Properties(); prop.load(new FileInputStream(config.properties)); Some properties are loaded,

  • 0

In this code:

Properties prop = new Properties();
prop.load(new FileInputStream("config.properties"));

Some properties are loaded, but does the fileinputstream need to be closed or does it somehow take care of that itself?

Do I need to create a variable, new file inputstream, then close the variable?

I was also wondering, if I create a variable, say, String a = null and int b;
Do they consume memory when they hold nothing?

and if I have that inside a method or a loop, does it still consume memory when out of scope?

I think someone once said it’s loaded into memory but not ‘active’?

  • 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-28T15:53:06+00:00Added an answer on May 28, 2026 at 3:53 pm

    Streams: Yes. Java doesn’t have destructors, so objects can’t take care of their own cleanup. Some amount of cleanup is done at garbage collection time (finalizers), but it’s not good programming practice to rely on that.

    One of the reason “finally” blocks exist in Java is to take care of resource deallocation.

    Memory allocation: looks like it does’t. I created the following program:

    public class deleteme
    {
        public static void main( String[] args )
        {
            int a;
            String s;
        }
    
    }
    

    Compiled it, then decompiled using javap -c, and got:

    public class deleteme {
      public deleteme();
        Code:
           0: aload_0
           1: invokespecial #1                  // Method java/lang/Object."<init>":()V
           4: return
    
      public static void main(java.lang.String[]);
        Code:
           0: return
    }
    

    Looks like nothing really happens, except for initializing my main class.

    Then i changed the code to say:

    int a = 1;
    String s = "";
    

    compiled, decompiled and got:

    public class deleteme {
      public deleteme();
        Code:
           0: aload_0
           1: invokespecial #1                  // Method java/lang/Object."<init>":()V
           4: return
    
      public static void main(java.lang.String[]);
        Code:
           0: iconst_1
           1: istore_1
           2: ldc           #2                  // String
           4: astore_2
           5: return
    }
    

    You can clearly see the additional instructions in the “main” method, where the memory is allocated.

    I have a feeling that different versions the Java compiler might handle this differently.

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

Sidebar

Related Questions

Introductory Example This code Properties.Settings.Default.MyUserSettingBlah = some new value; Properties.Settings.Default.Save(); saves the user.config file
This code does not seem to compile, I just need to write something to
I get child properties of an object with this code, PropertyDescriptorCollection childProperties = TypeDescriptor.GetProperties(theObject)[childNode.Name].GetChildProperties();
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
See the code here @interface StaticView : UIView { Properties *prop; } @property (retain)
I have this code in a Java EE Application for reading the Properties file.
public Properties prop = new Properties(); I get an illegal start of expression error
I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]
This code in JS gives me a popup saying i think null is a

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.