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


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

Re: Instantiation of a class

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!85.214.198.2.MISMATCH!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 21:57:26 -0400
Organization A noiseless patient Spider
Lines 21
Message-ID <ivg9md$c1c$1@dont-email.me> (permalink)
References <d98a873f-d5db-4243-be26-2109c25744b2@q12g2000prb.googlegroups.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 01:57:33 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="BrOwaJANne849xlH+KPYjQ"; logging-data="12332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oiWRJLYV5ulQfUccGXcu/"
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 <d98a873f-d5db-4243-be26-2109c25744b2@q12g2000prb.googlegroups.com>
Cancel-Lock sha1:r9GisrQCjcCOU1o+CHExi3EhF7w=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.help:848

Show key headers only | View raw


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.

-- 
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