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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:27:19+00:00 2026-06-02T18:27:19+00:00

Once the String object is created , we can’t modify it But if we

  • 0

Once the String object is created , we can’t modify it But if we do any operations on it JVM will create New Object. Here by creating new objects then JVM consumes more memory. Then i think it causes to memory issue right.?

  • 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-02T18:27:20+00:00Added an answer on June 2, 2026 at 6:27 pm

    You are correct. It is definitely worth being aware of this issue, even if it doesn’t affect you every time.

    As you say, Strings cannot change after creation – they’re immutable and they don’t expose many ways to change them.

    However, operations such as a split() will be generating additional string objects in the background, and each of those strings have a memory overhead if you are holding onto references to them.

    As the other posters note, the objects will be small and garbage collection will usually clean up the old ones after they have gone out of scope, so you generally won’t have to worry about this.

    However, if you’re doing something specific and holding onto large amounts of string references then this could bite you.

    Look at String interning depending on your use case, noting the warnings on the linked page.

    Two things to note:

    1) Hard coded String literals will be automatically interned by Java, reducing the impact of this.

    2) The + operator is more efficient in this regard, it will use String Builders underneath giving performance & memory benefits.

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

Sidebar

Related Questions

Once I created a form builder where user could select any number of fields
I'm using VBA to create a FileOpenDialog object so that the user can select
I'm writing an action method that will store a new object in a database.
I'm wondering what is the easiest way to persist a string value, once the
Strings are immutable, meaning, once they have been created they cannot be changed. So,
Once a user has selected a file with the open file dialog, how can
I know this sounds like a broad question but I can narrow it down
I have an object which I create from the response from a webservice. If
Question: how can I grab the newlines in a string entered into a textbox
Firstly, Im new to android but have years of various other programming experience on

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.