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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
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 1 May 2015 06:33:31 GMT
Organization Private site at Eddersheim, Germany
Lines 14
Distribution world
Message-ID <mhv6nr$lj4$1@Gaia.teknon.de> (permalink)
References <3eceaed0-2cfa-4fac-89d6-23445a670f84@googlegroups.com>
X-Trace individual.net lVdtZdxXzUSIy2SOoAkVDQJq4NEVC8Vqd3E/k+XZqHtvQEFeuc
Cancel-Lock sha1:plWWDW/y3e7wTHOUx8kT7jU+OtM=
Xref csiph.com comp.lang.java.programmer:31637

Show key headers only | 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