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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:52:12+00:00 2026-06-11T15:52:12+00:00

I agree with the fact that the String objects are immutable, means they cannot

  • 0

I agree with the fact that the String objects are immutable, means they cannot be modified. Like in the case below

String str = "Hi";
String str1 = str.concat("Nilesh");

Here the str object will be returned if the length argument is 0 or a new String object will be created and its reference will be returned.
And if i do

String str = "Hi";
str="Hello";

How is it getting changed? where does immutable comes into picture? An example please.

  • 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-11T15:52:13+00:00Added an answer on June 11, 2026 at 3:52 pm

    What is immutable is the String itself, not the reference that points to the String. In your second code:

    String str = "hi";
    str = "hello";
    

    There are 2 String objects involved: "hi" and "hello".

    str is a reference that originally points to the first one then points to the second one following an assignment. But the String object "hi" does not get modified in that code.

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

Sidebar

Related Questions

I agree that Functions are objects in JS. When using a Function as a
When it comes to password security there are things that people agree on like
I agree that this question is duplicate. Please bear with me. I was also
Most people would agree that internationalizing an existing app is more expensive than developing
I'm not sure I agree with it, so I'd like to find the book
I agree with the PHP Modifiers Reference in the 'm' modifier description that says:
I agree that the best way to shorten the ViewState is to disable it
I agree that using a namespace is essential for JavaScript libraries, but what about
I do agree with Mark Seeman's notion that Automatic Properties are somewhat evil as
I think most people agree that complying with W3C standards is a worthwhile pursuit.

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.