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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:44:05+00:00 2026-06-12T05:44:05+00:00

When creating a String object in Java, then concatenating something else to it via

  • 0

When creating a String object in Java, then concatenating something else to it via

someString.concat("I am being concatenated to someString");

or somesuch, since Strings are immutable, a temporary object is created that contains the resulting string, correct?
Usually, when this is done, a new String object is created right away to contain it, something like

String newString = oldString.concat("I am being concatenated");

but suppose that it isn’t. In that case, would there be another way to access the concatenated string? (In this last case, the sum of oldString and “I am being concatenated”.)

  • 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-12T05:44:07+00:00Added an answer on June 12, 2026 at 5:44 am

    Variables of non-primitive types in Java are references, they are not the objects themselves (as in C++). In a line like this:

    String newString = oldString.concat("I am being concatenated");
    

    there is not a new String object created in which the content of the imagined temporary string is copied. In fact, newString is going to refer to what you think is the temporary object. (There is not really a temporary object).

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

Sidebar

Related Questions

I'm having trouble creating an std::string (or any C++ object, I guess) in GDB.
I am creating a W3C Document object using a String value. Once I created
I am creating a FileOutputStream object. It takes a file or String as an
I am creating a web app that requires the use of a Java Object
Object[] o = a;b;c.split(;); o[0] = 42; throws java.lang.ArrayStoreException: java.lang.Integer while String[] s =
Hello i'm trying to convert my Java Object to a Json string to use
I am creating an array of string objects in PowerShell which needs to be
I've been instructed to write a model strdup by creating a String struct on
i'm attempting to instantiate a bunch of sounds by creating a string array containing
In VS2008, you could enable right-margin marks by creating a string registry entry named

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.