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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:27:06+00:00 2026-06-08T03:27:06+00:00

Possible Duplicate: Why does + work with Strings in Java? The following statements are

  • 0

Possible Duplicate:
Why does + work with Strings in Java?

The following statements are valid in Java.

int a=50;
String tmp="a = ";
String b=tmp+a;

b of type String now contains a = 50 (as a String).

Although tmp is of type String and a is of type int, the concatenation is made (even though Java doesn’t support operator overloading).

One of the reasons why Java doesn’t support operator overloading (as with other languages. In fact, I have no depth knowledge of any language).

Java does not support operator overloading. Operator overloading is sometimes a source of
ambiguity in C++ program, and the Java design team felt that it causes more trouble than
benefit.

More about it.

How is this statement String b=tmp+a; evaluated? There must be some equivalent concept of Operator Overloading internally.


Just one question : Can we see literally how it’s implemented or we should just believe “It’s just a feature of the language“?

I have heard that the Java compiler uses StringBuilder/StringBuffer (with the append() method) to achieve this but I’m not sure about that.

  • 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-08T03:27:08+00:00Added an answer on June 8, 2026 at 3:27 am

    Technically this is just a different operator that happens to have the same symbol. It’s the “string concatenation operator“; see section 15.18.1 of the Java Language Specification.

    Regarding implementation, the JLS has this to say:

    An implementation may choose to perform conversion and concatenation
    in one step to avoid creating and then discarding an intermediate
    String object. To increase the performance of repeated string
    concatenation, a Java compiler may use the StringBuffer class or a
    similar technique to reduce the number of intermediate String objects
    that are created by evaluation of an expression.

    For primitive types, an implementation may also optimize away the
    creation of a wrapper object by converting directly from a primitive
    type to a string.

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

Sidebar

Related Questions

Possible Duplicate: What does template <unsigned int N> mean? Hi ! Are non-type template
Possible Duplicate: Switch Statement With Strings in Java? Does the switch statement in Java
Possible Duplicate: How does Copy-local work? I have following situation: there's a project named
Possible Duplicate: How does JavaScript .prototype work? Coming from Java background, I'm trying to
Possible Duplicate: Why does .fireEvent() not work in IE9? Why these two statements are
Possible Duplicate: How does foreach work when looping through function results? If I have
Possible Duplicate: How does the (function() {})() construct work and why do people use
Possible Duplicate: How does this CSS triangle shape work? Please help me i need
Possible Duplicate: How does this work? Weird Towers of Hanoi Solution While surfing Google,
Possible Duplicate: how does jquery chaining work? This is a normal thing you would

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.