Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #850
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Instantiation of a class |
| Date | 2011-07-11 22:10 -0400 |
| Organization | A noiseless patient Spider |
| 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> |
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 | Next — Previous in thread | Next in thread | Find similar
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