Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31637

Re: If java doesn't support operator overloading, how does String + concatenation work

From v_borchert@despammed.com (Volker Borchert)
Newsgroups comp.lang.java.programmer
Subject Re: If java doesn't support operator overloading, how does String + concatenation work
Date 2015-05-01 06:33 +0000
Organization Private site at Eddersheim, Germany
Message-ID <mhv6nr$lj4$1@Gaia.teknon.de> (permalink)
References <3eceaed0-2cfa-4fac-89d6-23445a670f84@googlegroups.com>

Show all headers | View raw


Ajay Paul wrote:
> I understand that java doesn't support operator overloading.
> If so, how does String + concatenation work ? 

There is no method String::operator+() as there would be in C++.
String "+" is just "syntactic sugar", i.e. a shorthand notation
which is translated by the compiler into bytecode equivalent to
new StringBuilder().append(...).append(...).toString(). If you're
using Eclipse, get the "bytecode outline" plugin and see yourself.

-- 

"I'm a doctor, not a mechanic." Dr Leonard McCoy <mccoy@ncc1701.starfleet.fed>
"I'm a mechanic, not a doctor." Volker Borchert  <v_borchert@despammed.com>

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

If java doesn't support operator overloading, how does String + concatenation work Ajay Paul <ajaykpaul@gmail.com> - 2015-04-30 07:10 -0700
  Re: If java doesn't support operator overloading, how does String + concatenation work Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-04-30 11:32 -0400
    Re: If java doesn't support operator overloading, how does String   + concatenation work Robert Klemme <shortcutter@googlemail.com> - 2015-04-30 23:46 +0200
  Re: If java doesn't support operator overloading, how does String + concatenation work v_borchert@despammed.com (Volker Borchert) - 2015-05-01 06:33 +0000

csiph-web