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


Groups > comp.lang.java.help > #850

Re: Instantiation of a class

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.lang.java.help
Subject Re: Instantiation of a class
Date Mon, 11 Jul 2011 22:10:14 -0400
Organization A noiseless patient Spider
Lines 35
Message-ID <ivgaeb$d2v$1@dont-email.me> (permalink)
References <d98a873f-d5db-4243-be26-2109c25744b2@q12g2000prb.googlegroups.com> <ivg9md$c1c$1@dont-email.me> <lcadnRwToZK_NobTnZ2dnUVZ_oudnZ2d@earthlink.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 12 Jul 2011 02:10:19 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="BrOwaJANne849xlH+KPYjQ"; logging-data="13407"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zlawS12EyVm9Hm4rgXQ/c"
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11
In-Reply-To <lcadnRwToZK_NobTnZ2dnUVZ_oudnZ2d@earthlink.com>
Cancel-Lock sha1:EHttqZLXmGshH3sXf6ZLAZh0H9w=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:850

Show key headers only | View raw


On 7/11/2011 10:02 PM, Patricia Shanahan wrote:
> On 7/11/2011 6:57 PM, Eric Sosman wrote:
>> On 7/11/2011 7:03 PM, Fred wrote:
>>>
>>> I'm thinking about statements like String foo = new String("foo");
>>> When is the constructor specified not the name of the type of
>>> reference variable?
>>
>> Aside: The example is sort of silly, because one seldom needs
>> two instances of the same String.
>>
>> At the risk of answering a homework question, I can think of
>> two situations in which `x = new Y(...)' works even though x does
>> not have type Y. First, x's type may be that of one of Y's
>> superclasses, or of an interface implemented by Y. Second, the
>> class that's instantiated might not have a name the Java source
>> code can speak.
>>
>> And maybe the gurus will think of additional possibilities.
>>
>
> Unboxing:
>
> int x = new Integer(3);

     Ah, yes: autoboxing.  Worst pimple on the face of Java; I think
I overlooked it because a natural revulsion urged me to forget it.

> Yuck!

     Double yuck -- but thanks for pointing out the misfeature.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Instantiation of a class Fred <albert.xtheunknown0@gmail.com> - 2011-07-11 16:03 -0700
  Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-11 16:41 -0700
    Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-11 16:54 -0700
  Re: Instantiation of a class Mayeul <mayeul.marguet@free.fr> - 2011-07-12 02:02 +0200
  Re: Instantiation of a class Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-11 21:57 -0400
    Re: Instantiation of a class Patricia Shanahan <pats@acm.org> - 2011-07-11 19:02 -0700
      Re: Instantiation of a class Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-11 22:10 -0400
    Re: Instantiation of a class Fred <albert.xtheunknown0@gmail.com> - 2011-07-11 20:29 -0700
      Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-12 14:35 -0700
    Re: Instantiation of a class Gene Wirchenko <genew@ocis.net> - 2011-07-11 21:25 -0700
      Re: Instantiation of a class Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-12 07:47 -0400
        Re: Instantiation of a class lewbloch <lewbloch@gmail.com> - 2011-07-12 11:09 -0700

csiph-web