Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: Simple example for nested "new" expressions? Date: Sat, 16 Apr 2016 11:57:17 +0200 Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net 7SktNc/o1cCjlk+/xaMLSAEcX+uZxxgJaZuxrBAMkvanWhwVM= Cancel-Lock: sha1:9jdq1XWxl8IN2WTitYI38SsiTu8= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:34151 On 16.04.2016 04:09, Stefan Ram wrote: > I am searching for a simple example for the nesting of =C2=BBnew=C2=AB= > expressions, but it should not require the explanation of > certain =C2=BBadvanced=C2=AB features, such as exceptions, GUI > classes, type arguments or class declarations. I do not understand why one would want to teach "nested new=20 expressions". What is so special about invoking new for constructor=20 arguments? Basically you have a constructor invocation and pass on=20 references. One or more of those references just happen to point to=20 objects just created on the spot themselves. You can do this, but it seems to me as meaningless as to teach about=20 nested new: final Long l =3D new Long(new Integer(123)); final Long[] a =3D new Long[] { new Long(234) }; final Long[] b =3D { new Long(345) }; Kind regards robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/