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


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

Re: Simple example for nested "new" expressions?

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 <shortcutter@googlemail.com>
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 <dnegjuFl516U1@mid.individual.net> (permalink)
References <nested-new-20160416024157@ram.dialup.fu-berlin.de>
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 <nested-new-20160416024157@ram.dialup.fu-berlin.de>
Xref csiph.com comp.lang.java.programmer:34151

Show key headers only | View raw


On 16.04.2016 04:09, Stefan Ram wrote:
>    I am searching for a simple example for the nesting of »new«
>    expressions, but it should not require the explanation of
>    certain »advanced« features, such as exceptions, GUI
>    classes, type arguments or class declarations.

I do not understand why one would want to teach "nested new 
expressions".  What is so special about invoking new for constructor 
arguments?  Basically you have a constructor invocation and pass on 
references.  One or more of those references just happen to point to 
objects just created on the spot themselves.

You can do this, but it seems to me as meaningless as to teach about 
nested new:

   final Long l = new Long(new Integer(123));
   final Long[] a = new Long[] { new Long(234) };
   final Long[] b = { new Long(345) };

Kind regards

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

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


Thread

Re: Simple example for nested "new" expressions? Robert Klemme <shortcutter@googlemail.com> - 2016-04-16 11:57 +0200

csiph-web